Static-linking of SDL2 libraries

故事扮演 提交于 2019-11-28 18:26:59

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!