Could someone explain what the
__imp__fprintf
and
__imp____iob_func
unresolved external means?
Because I get these errors when I'm trying to compile:
1>SDL2main.lib(SDL_windows_main.obj) : error LNK2019: unresolved external symbol __imp__fprintf referenced in function _ShowError
1>SDL2main.lib(SDL_windows_main.obj) : error LNK2019: unresolved external symbol __imp____iob_func referenced in function _ShowError
1>E:\Documents\Visual Studio 2015\Projects\SDL2_Test\Debug\SDL2_Test.exe : fatal error LNK1120: 2 unresolved externals
I can already say that the problem is not from linking wrong. I have linked everything up correctly, but for some reason it won't compile.
I'm trying to use SDL2.
I'm using Visual Studio 2015 as compiler.
I have linked to SDL2.lib and SDL2main.lib in Linker -> Input -> Additional Dependencies and I have made sure that the VC++ Directories are correct.
I have finally figured out why this is happening !
In visual studio 2015, stdin, stderr, stdout are defined as follow :
#define stdin (__acrt_iob_func(0))
#define stdout (__acrt_iob_func(1))
#define stderr (__acrt_iob_func(2))
But previously, they were defined as:
#define stdin (&__iob_func()[0])
#define stdout (&__iob_func()[1])
#define stderr (&__iob_func()[2])
So now __iob_func is not defined anymore which leads to a link error when using a .lib file compiled with previous versions of visual studio.
To solve the issue, you can try defining __iob_func()
yourself which should return an array containing {*stdin,*stdout,*stderr}
.
Regarding the other link errors about stdio functions (in my case it was sprintf()
), you can add legacy_stdio_definitions.lib to your linker options.