SFML community forums

Help => General => Topic started by: Naralas on November 18, 2014, 11:09:49 am

Title: [Resolved] Problems to use the lib with QtCreator on Ubuntu
Post by: Naralas on November 18, 2014, 11:09:49 am
Hi,
I'm trying to include the lib on QtCreator but it doesn't work. If I install SFML with sudo apt-get install libsfml-dev I get the errors "undefined reference to...". If I install it "manually" I get the errors "cannot find lsfml-audio-d, lsfm-network-d,...". Here is my .pro file
QT       += core
QT       -= gui
TARGET = test_sfml
CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app

SOURCES += main.cpp

LIBS += -L"/home/ludo/SFML/lib"
CONFIG(release, debug|release): LIBS += -lsfml-audio -lsfml-graphics -lsfml-network -lsfml-window -lsfml-system
CONFIG(debug, debug|release): LIBS += -lsfml-audio-d -lsfml-graphics-d -lsfml-network-d -lsfml-window-d -lsfml-system-d
INCLUDEPATH += "/home/ludo/SFML/include"
DEPENDPATH += "/home/ludo/SFML/include"
 
If anyone could help me that would be great.
Title: Re: Problems to use the lib with QtCreator on Ubuntu
Post by: SeriousITGuy on November 18, 2014, 03:23:20 pm
Which version of Ubuntu do you use? Hopefully 14.04, as older versions had only SFML 1.6 in the official repos, since 14.04 Update 1, SFML 2.1 is in the repos.

When installing SFML via apt-get, it gets installed to /usr/, so normally you do not need to specify an additional include path for compiler and linker, as the gcc toolchain automatically searches in /usr/

What do you mean by installing it "manually"?
The normal manual installation method of SFML is by cloning from GitHub, and then building it yourself. This way it gets installed to /usr/local/, where the gcc toolchain also searches per default on Ubuntu 14.04.

I recommend you build it yourself from GitHub, cause the 2.1 version contains some linux specific bugs, which are ironed out in the git commits.

You can find a guide to this here (http://seriousitguy.blogspot.de/2014/11/how-to-setup-sfml-on-ubuntu-1404-lts.html)
Title: Re: Problems to use the lib with QtCreator on Ubuntu
Post by: Naralas on November 19, 2014, 11:57:59 pm
Im on Ubuntu 14.10 but as I said when I install it with the command apt-get install I can't use it, it keeps giving me the error "undefined reference".
Title: Re: Problems to use the lib with QtCreator on Ubuntu
Post by: SeriousITGuy on November 20, 2014, 10:03:26 am
Ok, if you install SFML via apt it gets installed to /usr/lib /usr/bin /usr/include etc.
From your project file I can see you add some path from your home-directory to the additional include paths.
Are the *.so files from SFML located there?

Otherwise search for the lib files, they are called lib-sfml-system-d.so and so on.
When you found this path add it to your project settings.
Do not forget to also add the include files from SMFL to your project settings.

In Code::Blocks everything works out of the box when installing SFML via apt or building it manually.
Maybe consult help in the QtCreator forum for specific help on how to add libs to project settings.
Title: Re: Problems to use the lib with QtCreator on Ubuntu
Post by: Naralas on November 20, 2014, 08:59:41 pm
Ok so I resintalled everything including cmake gcc compilator, etc.. and build it myself. Thanks for your help.