By Ethan Berman with some additions by Ed Parrish
This document describes how to install Code::Blocks and SFML on Linux for the course CS-11: Introduction to Programming Concepts and Methodology, C++. For Windows computers, see How to Install SFML in Code::Blocks for Windows. For Macintosh computers, see How to Install SFML in OS-X.
Code::Blocks is an Integrated Development Environment (IDE) used by many C++ software engineers and developers. An IDE is like a text editor with added features. It runs on the major platforms including Linux, OS-X and Windows. Code::Blocks is free, open source and configurable for use with different compilers including GCC/G++.
SFML is a free and open source library that provides a simple object-oriented interface to graphics, sound and other parts of a personal computer. It has five main modules: system, window, graphics, audio and network.
Code::Blocks can usually be installed in your distributions's app repositories. Use the following steps to install Code::Blocks.
sudo apt-get update sudo apt-get install codeblocks
The latest version of SFML is not typically stored as a binary in app repositories and thus often needs to be downloaded and compiled from source.
sudo apt-get install cmake
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 libudev-dev
If you have problems with dependencies, see Installing dependencies.
mkdir /home/<your user name>/development/sfml/
wget https://github.com/SFML/SFML/tarball/master tar zxf master rm master
Another download option is from the SFML Download page.
mv oldname sfmlbuild
cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=TRUE
Read through the notifications that appear and verify that CMake did not fail. If CMake did fail, recheck your steps.
make sudo make install
make commands fail, it is usually caused dependencies. See Installing dependencies.
cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug -D BUILD_SHARED_LIBS=TRUE . make sudo make install cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=FALSE . make sudo make install cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug -D BUILD_SHARED_LIBS=FALSE . make sudo make install
Make sure that after every CMake command you also enter the
make install commands or else SFML will not actually install.
Either click a shortcut to launch Code::Blocks or type the following in the Terminal window:
In this section we create a test project to verify the SFML installation. We can use these instructions as a starting point for other new projects as well.
The Code::Blocks procedure for using SFML is similar between Windows and Linux. Follow the Creating an SFML Project instructions in the document How to Install SFML in Code::Blocks for Windows.