C++ – Visual Studio 15 __imp___iob, __imp___pctype, __imp___mb_cur_max

clegacylinkerstdiovisual-studio-2015

I am trying to use a library compiled with mingw in visual studio. However, I get the following linker errors:

error LNK2001: unresolved external symbol __imp___iob

error LNK2019: unresolved external symbol __imp___pctype referenced in function

error LNK2019: unresolved external symbol __imp____mb_cur_max referenced in function

error LNK2001: unresolved external symbol _fprintf

I was able to fix the _fprintf error by linking against legacy_stdio_definitions.lib as per this post : unresolved external symbol __imp__fprintf and __imp____iob_func, SDL2.

However, I have no idea how to fix the other three unresolved externals. How can I fix this? The libraries work perfectly under Visual Studio 2013.

Edit:

Okay here is an update. I moved libmsvcrt.a from the mingw lib folder into Visual Studio, and I added that to the linker settings. Now it seems to work correctly.

Best Answer

The libraries were compiled against an old version of the CRT. The unresolved symbols you get are internal symbols of the CRT that are present in the compiled library. You have to recompile the library against the VS2015 CRT (the Universal CRT). But I'm not sure if MinGW supports this.

If you can't do that, you have to continue to use the VS2013 compiler. (You can use the VS2015 IDE, by setting the toolset to vs2013 in the project options. But you'll still be limited to the C++ features the 2013 compiler supports.)

Related Topic