error LNK2001 __imp_fprintf Visual Studio 2015 RC

2019-04-22 22:24发布

问题:

I recently was forced to upgrade from Visual Studio 2015 Pre-Release to Visual Studio 2015 Release Candidate as a result of an expired license.

My project was previously building fine, however, now it is not. I am getting only two link errors and I've spent the last two days attempting to address them:

    1>SDL2main.lib(SDL_windows_main.obj) : error LNK2001: unresolved external symbol __imp_fprintf
    1>SDL2main.lib(SDL_windows_main.obj) : error LNK2001: unresolved external symbol __imp___iob_func

I am linking to SDL2main as I got it from their website, I got the same error with version 2.0.0 and version 2.0.3, so I don't think it's an issue with the specific version.

I have the following directories specified for libraries (note the x64 folders, I am building 64 bit, I also built boost with "b2 address-model=64").

$(SolutionDir)../external/boost_1_58_0/stage/lib/
$(SolutionDir)../external/SDL/SDL2_ttf-2.0.12/lib/x64/
$(SolutionDir)../external/SDL/SDL2_mixer-2.0.0/lib/x64/
$(SolutionDir)../external/SDL/SDL2_image-2.0.0/lib/x64/
$(SolutionDir)../external/SDL/SDL2-2.0.0/lib/x64/
$(LibraryPath)

Note: I've tried SDL2-2.0.3 and SDL2-2.0.0 which is the one my previously working build used (with VS2015.)

I do not have Visual Studio 2013 installed and my platform toolset had to be upgraded to Visual Studio 2015 (v140) but I've also tried the only other option: Visual Studio 2015 - Windows XP (v140_xp)

What I am looking for is a straight-forward answer as to how to resolve this. I can offer further details if requested.

回答1:

SDL2main is not built against the same VS version as you are using, and there is no real guarantee anything in pre-release/RC versions is completely backwards compatible. If you have the source it is always a good idea to build everything yourself, with roughly the same build options - especially those for static/dynamic linking and multi-threading etc - so that you end up with libraries which are fully compatible with each other.

Also see this report