C++ – SDL DevC++ Linker Issue

cdev-c++sdl

I started the lazyfoo SDL Tutorials(http://lazyfoo.net/SDL_tutorials/lesson01/windows/devcpp/index.php) and i followed the install instructions exactly as written but when i compile this –>

#include "SDL/SDL.h"

int main( int argc, char* args[] )
{
   //Start SDL
   SDL_Init( SDL_INIT_EVERYTHING );

   //Quit SDL
   SDL_Quit();

   return 0;    
}

This happens –>

c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe skipping incompatible C:/SDL-1.2.15/lib/libSDLmain.a when searching for -lSDLmain

c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe skipping incompatible C:/SDL-1.2.15/lib\libSDLmain.a when searching for -lSDLmain

c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe skipping incompatible C:/SDL-1.2.15/lib/libSDLmain.a when searching for -lSDLmain

c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe cannot find -lSDLmain

c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe skipping incompatible C:/SDL-1.2.15/lib/libSDL.dll.a when searching for -lSDL

c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe skipping incompatible C:/SDL-1.2.15/lib/libSDL.dll.a when searching for -lSDL

c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe cannot find -lSDL

C:\SDL Tutorial Projects\collect2.exe [Error] ld returned 1 exit status

I have DevC++ 5.4.1 and im trying to install SDL-devel-1.2.15-mingw32.tar.gz

Does this have anything to do with my problem?

I've tried everything and it just says skipping incompatible for libSDLmain.a and libSDL.dll.a.

Best Answer

c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe skipping incompatible C:/SDL-1.2.15/lib/libSDLmain.a when searching for -lSDLmain

You may have incompatible binaries. Why are you using a x64 compiler? Try installing MinGW and compiling with raw gcc.

If you try that, add MinGW/bin to your path and run gcc 'filelocation' -lmingw32 -lSDLmain -lSDL

Or try using a x86 version of Dev. Also IIRC -lSDLmain should come before -lSDL and on Windows you need to add -lmingw32 for it to link and work properly.

If all this fails, one sure way would be to grab same MinGW and use msys to compile SDL yourself.. just change into the directory and run

./configure
mingw32-make
Related Topic