Crytrus
Crytrus

Reputation: 821

SFML play audio raspberry PI

Can't get SFML to work on Raspberry.

Can this be done? I need to play several soundfiles with short time between each one. And have successfully made a program on my mac. And this is going to be used on the RPi.

Have anyone done this successfully?

I have tried to set it up with g++ and with code::blocks but can't get it to work, I think it is something to do with linking the files. But now i am starting to wonder if it is at all possible?

If it is not, any suggestion of an easy (i am not that experienced) library for playing soundfiles one the raspberry pi using c++?

Hope someone can point me in the right direction quickly....

Upvotes: 2

Views: 1190

Answers (1)

William01110111
William01110111

Reputation: 33

I recently managed to get SFML 2.0 to work on my raspi but it was not easy. SFML 1.6 is available for raspberry pi with:

sudo apt-get install libsfml-dev

but I found this not to be compatible with my program written with SFML 2.X. I also tried and failed to use the Linux 32bit binary package SFML provides. I believe the reason for this is because the raspi uses the ARM processor which was not what that build was built for.

I finally succeeded by downloading the Linux source from the SFML download page. I got SFML 2.0 because the instructions I found for building SFML from source were for that version and it was new enough to be functional although you may want to try a newer version. I downloaded all the dependencies and attempted to install using the script I got here. This may work for you but I ran into problems with the freetype library. The solution I found was to copy all the freetype header files to the parent "include" directory. There may be a better way but that worked for me. I hope this helped.

Edit: I just had to do this again on a fresh Raspian install. This time I used SFML 2.3. I did not have the same problem with freetype but I did have to install the following dependencies:

sudo apt-get install libx11-xcb-dev
sudo apt-get install libxcb-image0-dev
sudo apt-get install libxcb-randr0-dev
sudo apt-get install libudev-dev

here are the scripts I used:

to install dependencies:

sudo apt-get install libpthread-stubs0-dev
sudo apt-get install libgl1-mesa-dev
sudo apt-get install libx11-dev
sudo apt-get install libxrandr-dev
sudo apt-get install libfreetype6-dev
sudo apt-get install libglew1.5-dev
sudo apt-get install libjpeg8-dev
sudo apt-get install libsndfile1-dev
sudo apt-get install libopenal-dev
sudo apt-get install cmake
sudo apt-get install g++

to build it:

echo Starting SFML 2.0 install
echo see install.log for install output..
echo No.. Really.. Read it, this is my first
echo batch script for linux, so expect bugs
echo especially because I can\'t be stuffed
echo using regex to look for error output


echo building make for dynamic release
cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=TRUE > install.log
echo Complete
echo making
make >> install.log
echo Complete
echo Installing
sudo make install >> install.log
echo Complete

echo building make for dynamic debug
cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=TRUE >> install.log
echo Complete
echo making
make >> install.log
echo Complete
echo Installing
sudo make install >> install.log
echo Complete


echo building make for static release
cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=FALSE >> install.log
echo Complete
echo making
make >> install.log
echo Complete
echo Installing
sudo make install >> install.log
echo Complete


echo building make for static debug
cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=FALSE >> install.log
echo Complete
echo making
make >> install.log
echo Complete
echo Installing
sudo make install >> install.log
echo Complete

to run these, simply

  1. copy them into a text file

  2. save it with the file extension .sh

  3. in properties, make it executable (or, in terminal : sudo chmod +x yourfile.sh)

  4. open it and click 'execute in terminal' (or, in terminal : ./yourfile.sh)

Upvotes: 3

Related Questions