Posts: 2
Joined: Tue Jul 26, 2016 2:43 pm

CROSS-COMPILING SDL2 for rpi3 - no audio.

Wed Jun 13, 2018 12:07 pm

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 using the crosstool-ng toolchain configured with rpi3 sample.

the error given by the SDL at runtime is :
Couldn't open audio device: No such device
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 :
undefined reference to 'vc_dispmanx_rect_set'
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.

User avatar
Posts: 47
Joined: Sat Dec 20, 2014 1:24 am
Location: Oklahoma, USA
Contact: Website Facebook Twitter YouTube

Re: CROSS-COMPILING SDL2 for rpi3 - no audio.

Mon Jul 09, 2018 8:06 am

maybe try this
copy Makefile to the folder with .cpp files then type "make"

Code: Select all

Basic Makefile for compiling target .cpp files with SDL2 libraries using g++.

#OBJS specifies which files to compile as part of the project
OBJS = $(wildcard *.cpp)

#CC specifies which compiler we're using
CC = g++

#COMPILER_FLAGS specifies the additional compilation options we're using
# -w suppresses all warnings

#LINKER_FLAGS specifies the libraries we're linking against
LINKER_FLAGS = -lSDL2 -lSDL2_image

#OBJ_NAME specifies the name of our exectuable
OBJ_NAME = $(patsubst %.cpp,%,$(wildcard *.cpp))

#This is the target that compiles our executable
all : $(OBJS)
Here is where I keep it updated ... 8eabe9cff4
Twitter: @farrownick
Instagram veggievampire
I own a lot of Pis....

Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 8 guests