Search code examples
c++visual-studiovisual-studio-2017linker

How to debug unresolved external symbols error in VS when lib is already added to additional dependencies


I'm using a C++ library that uses functions in wininet.lib. When I compile in VS2017 I get link errors.

I've added wininet.lib to the project's additional dependencies and made sure it's in the final commandline but still get the linker errors:

LNK2001 unresolved external symbol __imp_InternetOpenW

But everything compiles if I add:

#pragma comment(lib,"Wininet.lib")

To my code. I have another similar project that compiles fine with the same library without the #pragma.

How can I debug why VS2017 can't find a dependency when the lib is added to the additional dependencies?


Solution

  • You probably added wininet.lib only for a specific configuration or platform but built for another combination. Please have a closer look at your project properties. There're two drop down lists in the top most part of the properties dialog.

    This would at least explain why the #pragma works since it applies regardless of the chosen configuration and platform.