Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Installing SFML 2.0 on linux for dummies  (Read 37630 times)

0 Members and 1 Guest are viewing this topic.

falconmick

  • Newbie
  • *
  • Posts: 17
    • View Profile
Installing SFML 2.0 on linux for dummies
« on: November 26, 2012, 06:44:10 pm »
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 here

The 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 guide
sfmlcoder.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.
Quote
mkdir sfml2build
cd sfml2build

next download the latest sfml2 build and extract
Quote
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
Quote
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 sudo
Quote
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++
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
Quote
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

Quote
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.gz
Quote
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

you will probably get the following warning:

Quote
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

Quote
#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
« Last Edit: November 26, 2012, 08:03:49 pm by falconmick »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Installing SFML 2.0 on linux for dummies
« Reply #1 on: November 26, 2012, 07:08:23 pm »
Maybe you want to put that (also) in the official tutorial wiki section on GitHub. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Installing SFML 2.0 on linux for dummies
« Reply #2 on: November 26, 2012, 07:27:37 pm »
On Linux you probably don't need static and debug libraries. Only release/dynamic is relevant.

And I think it is a very long way to say

install dependencies
download sources
cmake .
make
sudo make install

... but I understand that some people need that level of detail ;)

I think there are two important pieces of information missing in your tutorial:
- once SFML 2 is released, it will quickly be in the repositories and all you'll have to do is "sudo make install libsfml2-dev"
- you can use git to update your local clone of the source tree
Laurent Gomila - SFML developer

falconmick

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Installing SFML 2.0 on linux for dummies
« Reply #3 on: November 26, 2012, 07:48:46 pm »
On Linux you probably don't need static and debug libraries. Only release/dynamic is relevant.

how so? I'm new to linux so this actually would be useful to know why

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Installing SFML 2.0 on linux for dummies
« Reply #4 on: November 26, 2012, 08:06:44 pm »
Static libs are not needed because Linux has a very good support for shared libraries. It might be useful until SFML 2 is released, because every version is different, but it's definitely not the final solution.

Debug libraries are not needed unless you plan to debug SFML itself.
Laurent Gomila - SFML developer

falconmick

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Installing SFML 2.0 on linux for dummies
« Reply #5 on: November 26, 2012, 09:02:59 pm »
Static libs are not needed because Linux has a very good support for shared libraries. It might be useful until SFML 2 is released, because every version is different, but it's definitely not the final solution.

Debug libraries are not needed unless you plan to debug SFML itself.

good point... didn't even think about that

main reason why I made this posts is I had some troubles getting this thing up and running, so I thought ide try to give back to the comunity what I could

garthos

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: Installing SFML 2.0 on linux for dummies
« Reply #6 on: December 16, 2012, 11:13:28 am »
I used the sfml2 cmake tutorials and found this was all I needed.
Infact I liked cmake so much I went on to install sfml2 sfml1.6 thor1.1 thor2

I did stumbled with the static libraries for sfml2. I compiled them fine.
But run out of puff when configuring code blocks. It look like I had to add each of those additional dependencies one by one to codeblocks build options. For each project. No thanks. Maybe at release time but not as curiosity.





Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Installing SFML 2.0 on linux for dummies
« Reply #7 on: December 16, 2012, 11:26:32 am »
Infact I liked cmake so much I went on to install sfml2 sfml1.6 thor1.1 thor2
Why have you installed multiple versions of each library, what do you expect from it? That will lead to incompatibilites sooner or later, don't do it. Only install the newest version of each library.

It look like I had to add each of those additional dependencies one by one to codeblocks build options. For each project. No thanks.
Doesn't Code::Blocks provide a possibility to add a set of dependencies/linker options at once, without repeating it for every project?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Republican31

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Installing SFML 2.0 on linux for dummies
« Reply #8 on: March 20, 2015, 07:51:39 pm »
Hi,

I don't understand how to add the links in CodeBlocks. I think I know where to add it, under Settings>Comiler>Linker, but I don't know what to put in the box to make it work.

Thank you

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Installing SFML 2.0 on linux for dummies
« Reply #9 on: March 20, 2015, 08:49:22 pm »
You really don't need to necro a 3 year old thread to say you have a problem. Not to mention the OP hasn't been active for over 3 years also.

Feel free to open your own thread and also verify that you have followed the official tutorial.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor