SFML community forums
Help => General => Topic started by: Tosh on October 19, 2009, 08:04:08 pm
-
I intended on using SFML for a linux project in my university, but this means that I can't use sudo (as the installation tutorial suggests). Is it possible for me to still use SFML in some other way? I have read a little about path environment variables and it sounds like something like that might help, but I don't know if that's correct, nor do I have any idea where to begin even if it is. Any help would be greatly appreciated =]
-
You just have to install it to a directory where you have write access (maybe /usr/local? oherwise just install it to /home/you/whatever).
Then, if you installed it to a directory that your linker doesn't know, you'll have to pass it to the compile command with "-Lpath/to/sfml".
That's it.
-
You'll need -I for the includes as well and might need some rpath fun for running the result ;)
-
When starting applications, you can also set the LD_LIBRARY_PATH environment variable so that shared libraries are found in a custom path.
-
Thanks a lot for the help guys, but I still haven't quite been able to get it to work x.x
The include errors are gone, so I think that part works, but it still doesn't seem to be linking properly. This is probably due to some misunderstanding about how things work on my part, but I thought that what I was doing made sense:
g++ test.cpp -I"SFML-1.5/include" -L"SFML-1.5/lib"
And the response:
/tmp/ccTV6P9l.o: In function `main':
main.cpp:(.text+0x74): undefined reference to `sf::Clock::Clock()'
main.cpp:(.text+0x81): undefined reference to `sf::Clock::GetElapsedTime() const'
main.cpp:(.text+0xae): undefined reference to `sf::Sleep(float)'
main.cpp:(.text+0xb9): undefined reference to `sf::Clock::GetElapsedTime() const'
collect2: ld returned 1 exit status
-
You have to link to the SFML libraries. Add "-lsfml-system" (same for all SFML modules that you need).
-
Okay, that was just me being stupid. Unfortunately, now that the bit linking to sfml-system is there, I can confirm that I am hopelessly stumped again:
vector38% g++ main.cpp -L"../SFML-1.5/lib" -I"../SFML-1.5/include" -lsfml-system
/usr/bin/ld: cannot find -lsfml-system
collect2: ld returned 1 exit status
vector38% ls ../SFML-1.5/lib
libsfml-audio.so.1.5 libsfml-network.so.1.5 libsfml-window.so.1.5
libsfml-graphics.so.1.5 libsfml-system.so.1.5
As far as I can tell, the files are exactly where it is looking for them. Also, it might be worth noting that the extent of my "installation" was to simply unzip the whole folder. I don't know if the actual install command in the makefile does something smarter than that, and my attempt to change the path it was pointing to just resulted in it telling me that a rule did not exist.
Sorry for wasting so much of your time, I'm just not used to doing things like this in linux, and I am finding it very difficult to find general information to help me using google.
-
ld looks for libraries ending with .so, so you have to create some symlinks, like libsfml-audio.so -> libsfml-audio.so.1.5 (do that with "ln -s libsfml-audio-so.1.5 libsfml-audio.so).
-
The "install" target of the SFML makefiles creates these symbolic links; so I guess that you copied the files manually instead of properly installing it :)
-
To make that work "DESTDIR" in src/Makefile must be adjusted. But you're right, that simplifies things, of course.
-
To make that work "DESTDIR" in src/Makefile must be adjusted
You can pass your own path:
make install DESTDIR=/home/sfml
-
That never worked on my side, strange.
-
Really? I'll test it next time I use my Linux.
-
No need to. It works, I guess I've done something wrong before. :)