I'm using Visual Studio 2008. I have a DLL and a test program EXE. There is a header file for the DLL that contains this:
#ifdef _DEBUG
#pragma comment(lib, "FooD.lib")
#else
#pragma comment(lib, "Foo.lib")
#endif
The intent is to dynamically link to FooD.dll through the FooD.lib import library, for a debug build, and to Foo.dll for a release build. The problem is that when I run the debug-build test program, it wants to be linked to Foo.dll.
I have verified that _DEBUG
is defined for the test program in a debug build. If I replace the #pragma comment
with an #error
directive, I see the error, so I'm pretty sure that the #pragma comment
is being processed as I expect.
I have also verified that both FooD.dll
and FooD.lib
exist. (Foo.dll
and Foo.lib
do not exist.) But at runtime, I get a "Cannot find Foo.dll" error message.
Any idea what might be going wrong, or where I can look to figure out why the incorrect DLL is being looked for at runtime?