Static-linking of SDL2 libraries

后端 未结 1 435
悲哀的现实
悲哀的现实 2020-12-08 05:54

I am using Windows 7, Code::Blocks and MinGW. I have little to no experience when it comes to compiling/building anything, especially when Code::Blocks doesn\'t use makefile

相关标签:
1条回答
  • 2020-12-08 06:01

    It's not necessary to recompile the library, SDL2 is given with static-link library named "libSDL2.a" on the folder "SDL2-2.0.0\i686-w64-mingw32\lib\".

    Just be sure to add these options to the linker :

    "-lmingw32 -lSDL2main -lSDL2 -mwindows -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -static-libgcc"

    on Code:Blocks at "Project / Build Options... / Linket settings / Other linker options"

    These options allow you to link with what SDL2.dll was using.

    You can retreive them on the file "SDL2-2.0.0\i686-w64-mingw32\bin\sdl2-config"

    The magical trick is to delete or rename the file "libSDL2.dll.a" on the folder "SDL2-2.0.0\i686-w64-mingw32\lib\". I added a "-" before to keep it in case I need it.

    I don't know why this librairy overcomes the other and a clue would be appreciated.

    I tried with Code::Blocks 12.11 MinGW32 and it worked.

    If you run with some projects that use dynamic-link and some other which use static-link, you will have to keep your librairies in two different folders knowing that "libSDL2main.a" will be in those two.

    Sorry for my writing, I'm not used to write in english.

    Mike

    0 讨论(0)
提交回复
热议问题