SFML Linking Problem

CodeLite installation/troubleshooting forum
Jalfor
CodeLite Curious
Posts: 5
Joined: Tue Apr 17, 2012 6:19 pm
Genuine User: Yes
IDE Question: C++
Contact:

SFML Linking Problem

Post by Jalfor »

I'm having an issue with linking SFML. The compiler obviously can work out where to find the SFML files, but linking is failing. I know how to do what I want to do right from the terminal, the command would be (assuming there was just one .cpp file and I only wanted to link to sfml-system) it would be:

Code: Select all

g++ -o appName main.cpp -lsfml-system
So, I thought I would just put

Code: Select all

-lsfml-system
and

Code: Select all

-lsfml-graphics
and so on into my linker options, but that doesn't appear to be working.

I don't think it matters, but the post at the top by the big scary mods says to put your system and stuff in your post, so here it is:

OS: Debian GNU/Linux
Compiler: GCC (g++)
Codelite: Compiled myself from svn repos because the Debian package is out of date

Thanks for any help
User avatar
Jarod42
CodeLite Expert
Posts: 240
Joined: Wed Sep 30, 2009 5:54 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: SFML Linking Problem

Post by Jarod42 »

in linker options,
add in Librairies:

Code: Select all

sfml-system;sfml-graphics
Jalfor
CodeLite Curious
Posts: 5
Joined: Tue Apr 17, 2012 6:19 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: SFML Linking Problem

Post by Jalfor »

Still no success. I assume the way you suggested is so they would link in the right order? Anyway, to eliminate that possibility, I only linked to sfml-system but still no success.
Jalfor
CodeLite Curious
Posts: 5
Joined: Tue Apr 17, 2012 6:19 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: SFML Linking Problem

Post by Jalfor »

Okay, I know EXACTLY what I need to do now. The output is:

Code: Select all

----------Build Started--------
/bin/sh -c '"make"  -j 2 -f "SFML_Executable_wsp.mk"'
----------Building project:[ SFML_Executable - Release ]----------
make[1]: Entering directory `/home/<me>/Documents/C++ Applications/SFML_Executable/SFML_Executable'
g++ -o ./Release/SFML_Executable @"/home/<me>/Documents/C++ Applications/SFML_Executable/SFML_Executable/SFML_Executable.txt" -L/usr/var/lib  -L.   
./Release/main.o: In function `main':
main.cpp:(.text.startup+0xa): undefined reference to `sf::Clock::Clock()'
main.cpp:(.text.startup+0x30): undefined reference to `sf::Sleep(float)'
main.cpp:(.text.startup+0x38): undefined reference to `sf::Clock::GetElapsedTime() const'
main.cpp:(.text.startup+0x4d): undefined reference to `sf::Clock::GetElapsedTime() const'
collect2: ld returned 1 exit status
make[1]: *** [Release/SFML_Executable] Error 1
make[1]: Leaving directory `/home/<me>/Documents/C++ Applications/SFML_Executable/SFML_Executable'
make: *** [All] Error 2
----------Build Ended----------
4 errors, 0 warnings
What I need to do to get it working, is fix this line:

Code: Select all

g++ -o ./Release/SFML_Executable @"/home/<me>/Documents/C++ Applications/SFML_Executable/SFML_Executable/SFML_Executable.txt" -L/usr/var/lib  -L 
I want to get rid of the -L at the end and replaces it with -lsfml-system. The command I want it to run is this:

Code: Select all

g++ -o ./Release/SFML_Executable @"/home/<me>/Documents/C++ Applications/SFML_Executable/SFML_Executable/SFML_Executable.txt" -L/usr/var/lib  -lsfml-system 
I've tested it in the terminal and it works. Now, could someone tell me how to do this in Codelite?

Thanks
Jalfor
CodeLite Curious
Posts: 5
Joined: Tue Apr 17, 2012 6:19 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: SFML Linking Problem

Post by Jalfor »

I found the answer. For anyone else that finds this problem, just remember that you have to right click on the project and open up the settings, not use the settings from the settings tab (Why is this?).

Anyway, all fixed now, and while I'm here, I'd just like to say, that this is a wonderful IDE, it has lots of customizability, a nice interface, great autocompletion, and just really nice to use.

Thanks
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: SFML Linking Problem

Post by eranif »

Jalfor wrote:I found the answer. For anyone else that finds this problem, just remember that you have to right click on the project and open up the settings, not use the settings from the settings tab (Why is this?).
Since the settings belong to the workspace / project. This is why I would expect it to be under the 'Workspace' menu (which it does exists) or from the context menu of the project (which also exists)

Eran
Make sure you have read the HOW TO POST thread
Jalfor
CodeLite Curious
Posts: 5
Joined: Tue Apr 17, 2012 6:19 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: SFML Linking Problem

Post by Jalfor »

Oh yes, I see. Thanks
Post Reply