views:

22

answers:

1

Hello,

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 functions 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,

A: 

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.

Hans Passant
Hmm, I hope they haven't missed that. Thank you, I should not have assumed they have included the lib file in both configurations.
SomethingBetter
@Something: what's happening? Time to close this thread perhaps?
Hans Passant
Hans: Thanks, the thread can be closed.
SomethingBetter