Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Random unresolved external symbols that shouldn't be there

I'm used to compiling for Linux so this .lib stuff is a bit weird for me. With my program under Visual Studio I keep getting random unresolved external symbol for other libs and even Microsoft Runtimes.

1>glfw3.lib(init.c.obj) : error LNK2019: unresolved external symbol __imp__vsnprintf referenced in function __glfwInputError
1>MSVCRTD.lib(vsnprintf.obj) : error LNK2001: unresolved external symbol __imp__vsnprintf
1>glfw3.lib(context.c.obj) : error LNK2019: unresolved external symbol __imp__sscanf referenced in function _parseVersionString
1>MSVCRTD.lib(vsnprintf.obj) : error LNK2001: unresolved external symbol __imp___vsnprintf
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\OLDNAMES.lib : warning LNK4272: library machine type 'UNKNOWN' conflicts with target machine type 'X86'

I am only including these libraries and I can confirm they are being found:

x86/glew32s.lib
x86/glfw3.lib
x86/glfw3dll.lib
opengl32.lib

With their inherited values:

kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib

I can confirm that this is the exact order. I have tried installing and re-installing Windows 7 SDK and Visual Studio - I am also on Windows 7.

Any help regarding this issue would be appreciated and I am happy to give out more information if required.

Thanks, Boncey

like image 628
Boncey Avatar asked Apr 10 '15 08:04

Boncey


2 Answers

You can also add an additional library to your linker input i.e, legacy_stdio_definitions.lib

Go to Properties > Linker > Input.

And in Additional Dependencies add the above mentioned library.

like image 132
Gurjot Bhatti Avatar answered Sep 30 '22 19:09

Gurjot Bhatti


It looks like there's a misconnect between dynamic and static runtime library linking. The "__imp" prefix on the symbols means your code is looking for something from a DLL, but the libraries you're linking in are probably expecting static runtime libraries.

Bring up the project property pages (under Build->Properties), and look for the C++ category on the left. Under "Code Generation" there should be an entry called "Runtime Library". This is probably currently set to Multi-threaded Debug DLL (/MDd), since it looks like you're compiling in debug mode. Change this to Multi-threaded Debug (/MTd), and recompile everything. See if that now works.

like image 45
Mark Morrison Avatar answered Sep 30 '22 21:09

Mark Morrison