How to Install SFML 2.0 into Ubuntu 12.04

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.

> cmake-gui

Now enter the paths to the binaries and the build folder into the window that pops up.

cmake1

Now press the ‘configure’ button and in the pop-up window just press the ‘Finish’ buton.

cmake2

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:

cmake3

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:

> 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 make install

(sudo is required since you are managing the /usr directory.)

Lastly you to update the files that contain the paths to the libraries using:

> ldconfig

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.

10 thoughts on “How to Install SFML 2.0 into Ubuntu 12.04

  1. Great tutorial! The only one that could help me after hours searching for a sfml 2.0 installation problem..

  2. This is exactly what tutorials should be. Simple, straight forward, and completely sensible.

    Not only that, but it works! You really should post more stuff.

  3. Thank you so much for this tutorial! It saved me a ton of time! A couple suggestions for you…

    1) libglew1.5-dev is no longer available in the apt packages. I used libglew-dev instead, and it seemed to work fine.

    2) I found that the ldconfig command must be executed using sudo as well.

    Thanks again!

  4. Great tutorial! Sfml should consider adopting this as theirs. The only thing i would add is that now they are on the release of sfml2.1. The github link above will download 2.1, so when you are installing dependencies you need to also run: sudo apt-get install libudev-dev. Tested on my 64 bit mint machine

  5. You should have a look here! Based on your article I wrote a version for SFML 2.1. It’s in German but to give credits to you I wrote the last paragraph in English and gave credits to you linking to this post. I hope you appreciate it. Keep up the great work! (:

  6. Pingback: SFML 2.1 unter Linux installieren | Dominik Muhs

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>