I need to link SDL2 statically in a DLL, but I'm having this error:
LNK2019: unresolved external symbol __imp___acrt_iob_func referenced in function "void __cdecl `dynamic initializer for '__iob_func''(void)" (??__E__iob_func@@YAXXZ)
The strange part is that when I build an .exe
, it all works fine, but when I change the configuration type to .dll
it doesn't. I found the following question:
unresolved external symbol __imp__fprintf and __imp____iob_func, SDL2
which looks like a duplicate, but not only I am building everything with the same compiler (VS2017), but I'm also not having problems if I don't link it statically.
I've tried the solutions there (rebuilding is N/A, adding definitions, and including legacy_stdio_definitions.lib
) to no avail.
I can only assume that the problem is in the code I'm linking statically (since the static build contains everything).
If somebody wants to reproduce, it's simple, you just have to build SDL-static and include the library in a DLL project. If you include SDL2.lib (dynamic) it works, if you include SDL2-static.lib in an .exe
project it works too.
PS: I'm using the same SDK and toolset to compile both SDL and the DLL that links it statically. I've rebuilt everything for each solution I tried.