SFML community forums
Help => General => Topic started by: tillis on April 25, 2012, 05:25:42 am
-
Hi. I have two issues.
Firstly, I am trying to get SFML 1.6 to work using Code Blocks on Ubuntu. I have followed the codeblocks tutorial on the website. I've added "/home/tillis/SFML-1.6/include" in compiler directory and "/home/tillis/SFML-1.6/lib" to the linker directory. "tillis" being my actual user name. :P In Linker settings I have added "-lsfml-system". I am trying to compile the clock sample.
Then I click build I get this message: cannot find -lsfml-system
It does work when the sfml files are in the /usr/local/ directories. But I specifically want to link them from my own home directories.
Secondly, even when SFML is in the /usr/local/ directories. I am trying to static link them using the "-lsfml-system-s" option, but this results in the error message "cannot find -lsfml-system-s".
What am I doing wrong here? : S
-
found this in search.... can you get it running at all?
Don't use static libraries on Linux, it will make things more complicated for you. Static libraries are useful only on Windows, other OSes manage shared libraries really well.
-
I have an AMD GPU, So SFML 1.6 apps hang unless they are staticly linked. So I really need it at the moment.
I can get it running without the windows or graphics modules if the libs are in the /usr/local/ directories. But I would prefer it if they were in directories within my home folder.
-
The ATI bug is only on Windows ;)
"/home/dean/SFML-1.6/lib"
If your home folder is "tillis", that would explain your problem :P
-
The ATI bug is only on Windows ;)
"/home/dean/SFML-1.6/lib"
If your home folder is "tillis", that would explain your problem :P
The directory names are all correct in code blocks. :P But code blocks just produces error messages saying it can't find "-lsfml-system" on Ubuntu.
As for my Windows install . Codeblocks is set up the same as on ubuntu, but it actually does find the libraries and compiles. but when I try "-lsfml-system-s" it says it can't find "-lsfml-system-s".
-
1. Like I said there should be no problem on Linux so you shouldn't need to use static libraries; your problem might be a different one
2. If the linker cannot find the library then you can trust him; check, re-check and re-re-check your project settings
3. Where did you get static SFML libraries for Linux?
-
If the ATI/AMD bug only effects windows than static wont be needed for linux. I've fixed the windows static problem, I re-read the tutorial and it seems codeblocks didn't have the right version of mingw as default. ._.
How would I set gcc/g++ to check a directory in a terminal for the headers on Ubuntu?
-
How would I set gcc/g++ to check a directory in a terminal for the headers on Ubuntu?
Hmm? What do you mean?
-
Okay, everything is working fine on Windows now. But on Ubuntu I still have a linking issues. I have the clock.cpp sample. I have SFML 1.6 installed in /home/me/SFML-1.6/
In terminal I type the following:
g++ -c clock.cpp -I/home/me/SFML-1.6/include
This works fine. And produces clock.o.
Then I enter: g++ clock.o -o clock -L/home/me/SFML-1.6/lib -lsfml-system
Which produces: /usr/bin/ld: cannot find -lsfml-system
The directory /home/me/SFML-1.6/lib has the following files within it.
libsfml-audio.so.1.6
libsfml-network.so.1.6
libsfml-window.so.1.6
libsfml-graphics.so.1.6
libsfml-system.so.1.6
Any ideas...?
-
For the linker to find -lsfml-system, there must be a libsfml-system.so file. This is not your case, your "lib" folder lacks the following symbolic links:
libsfml-system.so.1 -> libsfml-system.so.1.6
libsfml-system.so -> libsfml-system.so.1
You must create them.
-
Yes. That has worked. It now compiles into a executable file. :)
I am a little confused on the next step. I have copied libsfml-system.so.1.6 into say "/home/me/game/lib" and produced a libsfml-system.so file in the same folder which links to "/home/me/game/lib/libsfml-system.so.1.6" . the compile option "-L/home/me/game/lib/ -lsfml-system " works.
But when I attempt to execute the clock app by "./clock" it produces:
./clock: error while loading shared libraries: libsfml-system.so.1.6: cannot open shared object file: No such file or directory
I can run export "LD_LIBRARY_PATH=/home/me/game/lib" and it does work. But I want it to be fully portable. So it works on any ubuntu system that does not have SFML installed or the SFML LD path set up like that. In Windows I'd just put the .dll files into the same folder as the .exe file. What is needed in Ubuntu?
Thanks.
-
If you put the SFML libraries in the executable directory:
export LD_LIBRARY_PATH=.
;)
-
That works. :D :D
But I have come across another problem! When compiling SFML 1.6 from scratch. Following the tutorial here: http://www.sfml-dev.org/tutorials/1.6/start-linux.php
When I run the make command i get this:
make[1]: Entering directory `/home/me/SFML-1.6/src/SFML'
make[2]: Entering directory `/home/me/SFML-1.6/src/SFML/System'
g++ -shared -Wl,-soname,libsfml-system.so.1.6 -o ../../../lib/libsfml-system.so.1.6 Clock.o Lock.o Randomizer.o Sleep.o Unicode.o ./Unix/Initializer.o ./Unix/Mutex.o ./Unix/Platform.o ./Unix/Thread.o -lpthread
/usr/bin/ld: Unicode.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
Unicode.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [libsfml-system.so] Error 1
make[2]: Leaving directory `/home/me/SFML-1.6/src/SFML/System'
make[1]: *** [sfml-system] Error 2
make[1]: Leaving directory `/home/me/SFML-1.6/src/SFML'
make: *** [sfml] Error 2
-
Sorry, I have no idea about this error.
-
Some googling suggests it's a 64bit linking issue. (I am on 64bit ubuntu) :P
Compiling them into static libs works fine, so long as the two instances of NULL are replaced with 0 inside /SFML-1.6/include/SFML/system/ResourcePtr.int.
Either way, I can use the dynamic libs that come with SFML or compile my own static. Both works fine thanks to your help. ^^
These strange quarks are fun. :P