Jump to content
  • Advertisement
Sign in to follow this  
markblank

Problem installing SDL in visual studio 2015

This topic is 1675 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm trying to install sdl2 in visual studio 2015, and I'm having errors that I don't have in visual studio 2010.

 

1>------ Build started: Project: Mario Clone, Configuration: Debug Win32 ------
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>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\OLDNAMES.lib : warning LNK4272: library machine type 'UNKNOWN' conflicts with target machine type 'X86'
1>C:\Users\Acer Aspire\Documents\Visual Studio 2015\Projects\Mario Clone\Debug\Mario Clone.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 

I'm trying to refactor my game but I this error while testing this simple code.

 

#include <SDL\SDL.h>

int main(int argc, char* argv[])
{
   SDL_Init(SDL_INIT_EVERYTHING);
   return 0;
}

I include the x86 sdl lib, and target x86 machine, i also used Multi-threaded DLL (/MD) to remove this error:

?warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library

 

Share this post


Link to post
Share on other sites
Advertisement

Have you tried recompiling all of SDL yet and cleaning your build?

 

I haven't dabbled with SDL at all but these errors seem pretty generic. It looks like it's trying to link old versions of the libraries possibly built against a different platform and/or system.

Share this post


Link to post
Share on other sites
Hmm, thought I replied to this one already.

You'll need to recompile SDL2main and possibly change its use of fprintf to printf.

VS2015 contains a completely rewritten CRT with many bug and conformance fixes. It's not surprising that this kind of breakage happened; it's not clear if this is a temporary bug with the CRT being incompatible or if all static libraries (like SDL2main) will have to be recompiled for VS2015's runtime.

SDL is great and all, but its Windows support is a little odd at times. It still can't compile cleanly on the Windows 8 SDK out of the box, for instance (this is largely Microsoft's fault, honestly). The choice to ship SDL2main as a library instead of a header-only addition (it's not like it'll be included from more than one file) is just... problematic. As seen here.

Share this post


Link to post
Share on other sites

As the above two have already mentioned, it is probably a good idea to build the SDL2 source using Visual Studio 2015, and use the libraries built as a result to avoid issues with the CRT.

 

I haven't tried this because I don't have VS2015 yet.  Otherwise, I'd gladly contribute to this because my custom engine uses SDL.  So, give that a try if you can.  If you get build errors, feel free to share, and I'll see what I can do to help.

 

Shogun.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!