Crosscompilation toolchain in Linux (for building SDL2 applications)
Best crosscompilation choice is MXE project. It is fully automatized Makefile that downloads and builds all needed cross-tools and libraries.
At the time of writing this article, SDL2 was not yet ready to be built. If sdl2 is not installed, download SDL2-devel-mingw from official site and put include/
dir content into ./usr/include/SDL2
, lib/
to lib/
etc.
Now that all tools and libraries is installed simple Bash script that wraps normal make
invokation would do all the work:
All user libs and includes should go to ./usr/{lib,include}
dirs resp. Normally any .dll
file can be used by linker, so there is no need to make .a
files.
Troubleshooting
Some old MinGW C++ STL versions do not suppport to_string
and other standard string conversion routines. Fix for that problem is described here
If Undefined reference to 'SDL_main'
errors pop up, make sure that main
routine is declared as following:
If linker is cursing with messages like ‘undefined reference to SDL_Init’ and such, check order of arguments in gcc invokation: