Cross-Compilling SDL2 for rpi3 - no audio


Hello, I’m trying to cross compile my program that uses SDL2 as a library for audio. I already cross-compiled my program and SDL2 as a static library. and the program run fine on rpi3 except is as no sound. (i’m not using SDL_mixer)

I’m using the crosstool-ng toolchain configured with rpi3 sample.

the error given by the SDL at runtime is :

it appears that my SDL library is not compiled with ALSA support.
so I tried to compile SDL 2 on my raspberry, it compiles and found ALSA as an audio driver but I have an error when linking with my program :

and many other errors in rpimouse.h for example.

I’m using the ./configure make install procedure.

I tried to cross-compile alsa on my laptop and put it in my sysroot, but it doesn’t found alsa when configuring.

I do not know what to do, if someone knows how to solve the undefined reference, or to include alsa in cross-compiling, it would be the best day for me.


This probably doesn’t help you, but the version of SDL2 at the Raspberry Pi repository certainly supports sound:

sudo apt-get install libsdl2-2.0-0


This implies that you’re not linking to one of the required libraries. From what I can tell that one isn’t in SDL at all and is probably related to the video functions.

Are you using the output of sdl2-config --libs to ensure that proper linkage is occurring? This thread seems to have the same issue as you do, and using the sdl2-config --libs seems to get it working for them.

I don’t have a Pi currently, so I’m working on theory and speculation here. Hope it helps.

Also, when you’re creating your toolchain scripts with CMake, are you sure you’re enabling ALSA support? Do the demos or samples for SDL2 work/compile normally?


Thx for your answers! I did not precise that my application works perfectly fine on x86_64 application with compiled SDL2, and there is sound. also, I try to be no dependent of user libraries, so I use SDL as a static library. I link my program with libSDL2.a

the sdl2-config --libs script doesn’t help, I have already all these options!

to compile SDL2 I don’t use a cmake toolchain script, only ./configure with the “host” argument.