My setup: Ubuntu 20.4, gcc version 9.3.0, SDL version 2.0.10
Install mingw64, by running the following command:
sudo apt install mingw-w64Clone SDL2 source:
git clone http://hg.libsdl.org/SDL
cd SDL/Make build/ directory:
mkdir build
cd buildConfigure for Windows64bit:
../configure --prefix=/tmp/sdl2-win64 --host=x86_64-w64-mingw32or
Configure for Windows32bit:
../configure --prefix=/tmp/sdl2-win64 --host=x86_64-w64-mingw32Make:
make
make installNow we should get SDL2.dll and other files at /tmp/.
For 64bit Windows:
x86_64-w64-mingw32-g++ test.cpp -I/tmp/sdl2-win64/include/ -L/tmp/sdl2-win64/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -o test.exeor
For 32bit Windows:
i686-w64-mingw32-g++ test.cpp -I/tmp/sdl2-win32/include/ -L/tmp/sdl2-win32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -o test.exeYou may also need to include headers located in the folder with SDL source code you downloaded earlier: -I/some/path/SDL/include/
(This is assuming you have #include <SDL2/SDL.h> in your files)
To ship it, you will need the executable and a few .dll files. If you run your exec it should tell what dlls does it need.
For me (and most basic Windows 64bit SDL applications) it was:
(path to git cloned SDL)/SDL/build/build/.libs/SDL2.dll
/usr/lib/gcc/x86_64-w64-mingw32/9.3-win32/libgcc_s_seh-1.dll
/usr/lib/gcc/x86_64-w64-mingw32/9.3-win32/libstdc++-6.dllFor 32 bit:
(path to git cloned SDL)/SDL/build/build/.libs/SDL2.dll
/usr/lib/gcc/i686-w64-mingw32/9.3-win32/libgcc_s_sjlj-1.dll
/usr/lib/gcc/i686-w64-mingw32/9.3-win32/libstdc++-6.dll (very likely)
/usr/i686-w64-mingw32/lib/libwinpthread-1.dllGame I compiled: https://github.com/Cuber01/sand-game