That pragma
is used to link against the specified .lib
file. This is an alternative to specifying the library in the external dependencies field in project settings.
Mostly, it’s used to support different versions:
#ifdef USE_FIRST_VERSION
#pragma comment(lib, "vers1.lib")
#else
#pragma comment(lib, "vers2.lib")
#endif
When your application uses a dynamically-linked library, a lib
file tells you information about what symbols are exported in the dll
. So basically you only need the lib
to compile & link, but you need the dll
to run the program, as it contains all the binary code.
You say there’s an associated dll
, which usually indicates the lib
file only contains linking info, and no code. You should get a run-time error if the associated dll
was not found. You can check with MSVS if a different version of the dll
was loaded or if it was loaded from a different place.