Question

I am working on an (unmanaged) x64 Win32 C++ application in Visual Studio 2010 Pro, and keep getting a strange linking error.

This application makes use of the LoadImage() Windows API function through including windows.h. While the application compiles fine in the Release configuration (and LoadImage() does its job), I cannot get the executable linked in the Debug configuration. I keep getting this error:

Redacted.obj : error LNK2019: unresolved external symbol __imp_LoadImageW referenced in function "public: int __cdecl Redacted::Redacted::Execute(void)" (?Execute@Redacted@Redacted@@QEAAHXZ)
C:\Users\redacted\Documents\Visual Studio 2010\Projects\Redacted\x64\Debug\Redacted.exe : fatal error LNK1120: 1 unresolved externals

If I switch from Unicode to non-multi-byte character set, the error message will change from LoadImageW() to LoadImageA() accordingly, but otherwise persist. As I cannot find any relevant differences in the properties for the Release and Debug configuration, I am at a loss why it will compile in one, but not the other. User32.lib is correctly set as an Additional dependency for the Linker in both configurations, and the /MACHINE:X64 flag is set in both as well.

Since the linker doesn't complain about not finding the User32.lib, I am led to believe that it tries to link a wrong version from the Platform SDK, i.e. the 32-bit one. But how can I find out which exact copy of a LIB file the linker actually tries to use?

Was it helpful?

Solution

Check the linker paths in the global configuration settings. Most probably one of those is wrong.

Beyond that, I believe there's a linker /VERBOSE flag (or something similar) which will display the information you're looking for. It's somewhere in the linker settings for the project you're building.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top