开发者

Linker error with debug build with different compiler versions

We have a DLL, built with MS Visual Studio 2010, in release mode. We provide this DLL to different customers, along with a .lib file. The functions in the DLL are exported with:

extern "C" __declspec(dllexport) int analyze(int id);

Our customers have two applications that makes use of this DLL. Both of these applications import the DLL functio开发者_Python百科ns using:

extern "C" __declspec(dllimport) int analyze(int id);

One of these applications is built with MS Visual Studio 2010. This application can be built successfully in both debug and release modes.

The other application must unfortunately use MS Visual Studio 2005 as its build environment. In this application, the release build can be built successfully, however, when we try to build in debug mode, we get linker errors:

LNK2019: unresolved external symbol __imp_analyze referenced in function "void __cdecl process(char const *,char const *)" (?process@@ABCERFG0@Z)

Can someone help me understand what we are missing here? Are we exporting the functions in a manner that is not portable across compilers? What's the solution?

Regards,


The .obj file format is highly conserved between VS2005 and VS2010. This should not be a problem, especially since it is a simple non-mangled symbol reference. And especially not when it works in the Release configuration but not in Debug. A simple explanation is always better than a convoluted one: your customer simply forgot to add your .lib file to the linker's Additional Dependencies setting.

Beware that the setting change needs to be made for both configurations, use the "Configuration" combo in the upper left corner of the dialog.

You can help your customer fall into the pit of success by using #pragma comment(lib, "mumble.lib") in your .h file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜