Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 15 __imp___iob, __imp___pctype, __imp___mb_cur_max

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.

like image 798
stack_tom Avatar asked Jul 21 '15 18:07

stack_tom


2 Answers

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.)

like image 69
Sebastian Redl Avatar answered Sep 26 '22 00:09

Sebastian Redl


I encountered the same problem (library compiled with static CRT instead of CRT in DLL) and I managed to make it work by changing the two following parameters in Project Properties:

  • Linker > Input > Ignore specific default libraries: libc.lib
  • C/C++ > Code Generation > Runtime Library: Multi-threaded Debug (/MTd)

If that's not enough, there's more at following page: https://social.msdn.microsoft.com/Forums/en-US/841e5723-bce4-4340-b7b3-027dcdf90f00/

like image 42
FlorianT Avatar answered Sep 22 '22 00:09

FlorianT