Ok... I've gone through figuring out how to install SFML on my Ubuntu installation and it wasn't easy to be perfectly honest... Allot of the guides did allot of talking and didn't just KISS (keep it simple stupid) So I decided to make this guide.
This guide assumes a fresh install and that you are running Ubuntu... It is how I tested to make sure my commands worked, if you are running a non fresh install OR not running Ubuntu you might either a. already have some of the files I install with apt-get OR they mightn't be working on your distro. If there is a distro where my guide doesn't work please tell me it and I will go about appending this guide to help those who run that OS.
There are two semi-long scripts and a test codeblocks project, if you wish to download them to make things easier/test everything setup correct you may download it from
hereThe only problem with a guide like this is that it's instructions and tools will become out of date.. If you stumble apon this post in a few years and I havn't updated it, then I would recomend that you look for more up to date guides. If you have problems and this guide is still relivent, there might be an individual problem in your setup which a propper guide can help you with, please see the following guides to help you figure all this out:
sfml-dev.org guidesfmlcoder.wordpress (better guide) github (also has other usefull SFML related tutorials) Well enough jibber jabber, I better get to the guide or I wouldn't be KISS'n
Step 1. Download the latest SFML 2.0 build
open your terminal and create a new directory and cd into it
i.e.
mkdir sfml2build
cd sfml2build
next download the latest sfml2 build and extract
wget https://github.com/SFML/SFML/tarball/master
tar zxf master
rm master
then if you look into your sfml2build folder using the folder browser or the dir command you will see one fodler:
LaurentGomila-SFML-59a68f0
Day per day, this folder will change as build's are updated.. so I would recommend changing the filename, this can either be done through linux gui or through this command
mv #your folder name# sfml2src
sfml2src being the new folder name
next is step two, installing requirements..
Just run the following script (as in, make a text file, coppy/paste this, change permission of file to execute and run
see getReq inside of tools.tar.gz ADD sudo infront of apt-get install g++ in getReq.. forgot the sudosudo 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++
save it is getReq inside of sfml2build folder
you can either double click it to run or (better option) get into the console you used for step one and type ./getReq
it will ask for sudo password (your password) and then it will install all the requirements.
it will ask if you wish to install on each thing it attempts to install, hit enter
Do you want to continue [Y/n]?
.
Step 3.. Almost done!!
next I will give you a neat little script I made to configure, make and install sfml
first cd into sfml2src or what ever you called it
cd sfml2src
just coppy/past this quote and do as you did with getReq (call it installer this time and save it inside of sfml2src folder)
see installer inside of tools.tar.gzecho 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
you will probably get the following warning:
CMake Warning at CMakeLists.txt:150 (message):
No pkg-config files are provided for the static SFML libraries
(SFML_INSTALL_PKGCONFIG_FILES will be ignored).
I'm pretty sure it's harmless, I ignored it.
and that's it, the latest SFML 2.0 build should be installed
to test it's working you can download
tools.tar.gz #include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
unfortunatly, I couldn't find where codeblocks liked to store my templtates so I you're gonna have to link it urself.. it's not too hard though
you have 4 linking options (ill use graphics lib as an example)
libsfml-graphics release with dynamic libraries
libsfml-graphics-d debug with dynamic libraries
libsfml-graphics-s release with static libraries
libsfml-graphics-s-d debug with static libraries
you then also must link (for the demo to work)
libsfml-window( /-d/-s/-s-d)
libsfml-system( /-d/-s/-s-d)
if you build with static libraries you must also include the libraries used by SFML which are:
pthread
GL
X11
Xrandr
freetype
GLEW
jpeg
sndfile
openal
but if you dynamically link you don't need to link these
I hope this helps someone
any troubles just send me a pm or better yet, reply to this post so I can help people with similar issues!!!
edit 1:
had to re-upload tools.tar.gz, didn't realise, but codeblocks was breaking when I uploaded the project file
edit 2:
added github tutorial link
edit 3:
re-fixed tools.tar.gz, hosting site spazzed
edit 4:
ok... rapidshare is glitchy, changing to localhostr
edit 5:
added source