So this tutorial will take you through the installation of SFML 2.0 into a freshly installed version of Ubuntu (12.04.2) using the latest snapshot available. I have taken a mix of these steps from the SFML website and SFML Coder’s website. If you would like further clarification on things I’ve said you can try to look at those tutorials.
So what is the snapshot? Well the snapshot is just the current working version of the source code of SFML 2.0. You can view the source code here if you’re interested. But just like any other program, in order to use it we need to build and run (aka install) it. Which I will explain more later.
Step 1: Download the required libraries/programs
First in the terminal we will need to download cmake and the cmake gui. This is what we will use for building the binaries.
> sudo apt-get install cmake
> sudo apt-get install cmake-qt-gui
After cmake is installed, we can now download the library dependencies for SFML 2.0 to work.
> sudo apt-get install g++
> 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 libgpgme11-dev
> sudo apt-get install libsndfile1-dev
> sudo apt-get install libopenal-dev
Lastly, if you want to download the documentation, you will need to install doxygen. Otherwise this step is not required.
> sudo apt-get install doxygen
Now we can download the snapshot and build the binaries!
Step 2: Download the latest snapshot
The latest snapshot of SFML 2.0 can be found at:
By clicking this link you will download a file with the name LaurentGomila-SFML-2.0-xxxxxxxx.tar.gz where the x’s relate to the latest commit made in github.
From here you just need to unpack the binaries:
> tar xvf LaurentGomila-SFML-2.0-xxxxxxxx.tar.gz
Lastly before actually starting cmake, I’m going to rename the binary folder (for simplification) and create a build folder in the same directory where the generated code will go:
> mv LaurentGomila-SFML-2.0-xxxxxxxx SFML2
> mkdir SFML2-build
Now we can use cmake to build the binaries.
Step 3: Build the binaries
In the command line (or just by searching for the application) open up the CMAKE GUI.
Now enter the paths to the binaries and the build folder into the window that pops up.
Now press the ‘configure’ button and in the pop-up window just press the ‘Finish’ buton.
Now the table in the middle will be populated and you can select whether or not you want to install the examples (SFML_BUILD_EXAMPLES) or the documentation (SFML_BUILD_DOC). I selected to install both as shown below:
If you selected to install the documentation or examples you must reconfigure. Otherwise you can just press the ‘generate’ button.
After you are prompted that the generation is done you can close the cmake gui.
Step 4: Compiling and installing the binaries
So now you’re ready to compile and install the binaries. First navigate to the build folder directory.
> cd /path/to/SFML2-build
And compile the binaries using make:
Once the files are all compiled, you now need to install them into the /usr/local/lib/ folder. The make file has a compile option that lets you do this easily:
(sudo is required since you are managing the /usr directory.)
Lastly you to update the files that contain the paths to the libraries using:
After this SFML 2.0 should now be installed! You can test this by running any of the example programs or by running the sample code from the SFML website.