Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-compiling SDL 2.0 application between supported platforms

I'm looking for a "Hello World" SDL 2.0 project that cross-compiles between all supported platforms: Windows, Linux, Mac, Android and iOS. Is there anything like that? I could not find on the official forums or docs.

What tools are recommended? CMake or SCons? Can it be done with just "make"?

like image 936
vinnylinux Avatar asked Sep 26 '13 18:09

vinnylinux


2 Answers

Don't know if that's exactly what you're looking for, but I've just made a small tutorial on how to cross-compile SDL2 projects from Linux to Windows. Dead Link

Basically, install MinGW and set your compilation flags to the following (Makefile example):

# Where your MinGW SDL is installed
SDL_ROOT_DIR = /usr/x86_64-w64-mingw32

CFLAGS   = `$(SDL_ROOT_DIR)/bin/sdl2-config --cflags`
           -Wall -Wextra
CXXFLAGS = `$(SDL_ROOT_DIR)/bin/sdl2-config --cflags`
           -Wall -Wextra
LDFLAGS  = `$(SDL_ROOT_DIR)/bin/sdl2-config --libs` \
           -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lSDL2_gfx \
           -static-libgcc -static-libstdc++

In-depth explanations here and here.

like image 134
alexdantas Avatar answered Oct 27 '22 20:10

alexdantas


If you download the source for SDL2, there are a number of short example programs that compile on all supported platforms in the "test" directory.

like image 28
Darius Makaitis Avatar answered Oct 27 '22 21:10

Darius Makaitis