SDL2 auf RaspberryPi2 B kompilieren
Für mein Projekt benötige ich SDL2 auf der RapsberryPI 2
ACHTUNG: Bug in SDL/Mixer wenn man WAV Dateien laden/abspielen möchte!
Fix: Bibliotheken neu erstellen und folgenden Patch für SDLMixer anwenden:
https://github.com/kripken/emscripten/issues/3985
http://pastebin.com/raw/iJwfCCzu
und danach das Verzeiuchnis SDL_mixer nach $EMSCRIPTEN/system/include/SDL kopieren (SDL_mixer.h)
Nun funktioniert alles wie es sollte ;-)
Kompilieren unter Emscripten(KEIN MIXER):
USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["png"]' -s USE_SDL_TTF=2
Kompilieren:
g++ `sdl2-config --libs` -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer
D.H. alles selbst compilieren, hier die Schritte die ich benötigt habe
Vorbereitungen
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential libfreeimage-dev libopenal-dev libpango1.0-dev libsndfile-dev libudev-dev libasound2-dev libjpeg8-dev libtiff5-dev libwebp-dev automake
SDL2
wget https://www.libsdl.org/release/SDL2-2.0.3.tar.gz
../configure --host=armv7l-raspberry-linux-gnueabihf --disable-pulseaudio --disable-esd --disable-video-mir --disable-video-wayland --disable-video-x11 --disable-video-opengl
tar zxvf SDL2-2.0.3.tar.gz
cd SDL2-2.0.3 && mkdir build && cd build
../configure
make -j 4
sudo make install
SDL2_image
wget https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.0.tar.gz
tar zxvf SDL2_image-2.0.0.tar.gz
cd SDL2_image-2.0.0 && mkdir build && cd build
../configure
make -j 4
sudo make install
SDL2_ttf
wget https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.14.tar.gz
tar zxvf SDL2_ttf-2.0.14.tar.gz
cd SDL2_ttf-2.0.14 && mkdir build && cd build
../configure
make -j 4
sudo make install
SDL2_mixer
Achtung: SDL_mixer will smpeg (videolibrary) zum abspielen von mp3! Diese muss fü rden C11 compiler gepachted werden!
Ausserdem benötige ich die SDL_Mixer library statisch
smpeg
wget https://github.com/Distrotech/smpeg
tar zxvf smpeg.tag.gz
cd smpeg
###PATCH -> https://github.com/flathub/shared-modules/blob/master/smpeg/smpeg-gcc6.patch
chmod +x autogen.sh
./configure
make -j 4
sudo make install
SDL2_mixer
wget https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.tar.gz
tar zxvf SDL2_mixer-2.0.1.tar.gz
cd SDL2_mixer-2.0.1 && mkdir build && cd build
../configure --enable-static --disable-shared
make -j 4
sudo make install
DONE!
compilieren mit (sdl2-config):
g++ `sdl2-config --cflags --static-libs` main.cpp -lSDL2 -SDL2_image -lSDL2_ttf -lSDL2_mixer
Auf der RaspberyPI ohne X11 Desktop kann SDL keine Fenstergrösse setzen.
Daher müssen wird das nehmen was nehmen was vorgegeben ist (1920x1080).
Mit diesen Präprozessor Anweisungen kann man beim kompilieren die Fenstergrösse der Pi anpassen.
#ifdef __arm__
#define SCREEN_WIDTH 1920
#define SCREEN_HEIGHT 1080
#else
#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 450
#endif