SFML community forums
Help => General => Topic started by: TheFloatingBrain on December 04, 2014, 01:37:19 am
-
Hello!
Wow! It has been a while since I was here last! Whats up ;D ? I wonder if there are any other old SFMLers here, give me a shout if you used SFML back in 2009/2010 XD ? Anyway, I decided if I may just want to port an old project to linux http://gcggames.webs.com/WSL/Site/main.html (http://gcggames.webs.com/WSL/Site/main.html), and I also wanted to use the new release for future proejcts (or port the project over to SFML 2.1). So I made a few switch scripts to switch from SFML 2.1, and SFML 1.6 on my system:
#!/bin/bash
if [ $1 = "-h" ] || [ $1 = "--help" ]; then
echo "-h This help diolouge."
echo "-sfml16 Set up SFML 1.6"
echo "-sfml21 Set up SFML 2.1"
echo "-clean Clean all links, do not set up a SFML"
else
echo "Dont mind the clean up errors."
sudo unlink /usr/include/SFML/SFML16
sudo unlink /usr/include/SFML/SFML21
sudo unlink /usr/include/SFML
sudo unlink /usr/lib/SFML16
sudo unlink /usr/lib/SFML21
sudo unlink /usr/lib/SFML/SFML16
sudo unlink /usr/lib/SFML/SFML21
sudo unlikn /usr/lib/SFML
sudo rm /usr/include/SFML
sudo rm /usr/lib/SFML
echo "Clean up complete, starting link."
if [ $1 = "-sfml16" ]; then
sudo ln -s /usr/include/SFMLInclude/SFML16 /usr/include/SFML
sudo ln -s /usr/lib/SFML16 /usr/lib/SFML
else
if [ $1 = "-sfml21" ]; then
sudo ln -s /usr/include/SFMLInclude/SFML21 /usr/include/SFML
sudo ln -s /usr/lib/SFML21 /usr/lib/SFML
fi
fi
fi
It works fine when I am using SFML 2.1 where the library .so files are in /usr/lib/SFML21 and have a symbolic link to /usr/lib/SFML, and where the include files are in /usr/include/SFMLInclude/SFML21 with another symbolic link to /usr/include/SFML
However while the symbolic links and such work with SFML 1.6 (i.e ls /usr/lib/SFML shows the 1.6 files), the linker cant seem to find the files when I try g++ -std=c++11 -L /usr/lib/SFML -m64 -l sfml-graphics -l sfml-window -l sfml-system test.cpp
(I have tried rearranging the commands and omitting the -std=c++11 flag).
The 1.6 files are in /usr/lib/SFML16 and /usr/include/SFMLInclude/SFML16 and the symbolic links seem to work, I tried running ldcondfig but it did nothing.
Any help is appreciated!
Thanks :-)
- TFB
-
I figured it out! It was not too hard, all I did was make symbolic links for all the shared libraries like so:
Prototype:
ln -s /usr/lib/SFML/libMODULE-sfml.so.1.6 /usr/lib/SFML/libMODULE-sfml.so
Example:
ln -s /usr/lib/SFML/libgraphics-sfml.so.1.6 /usr/lib/SFML/libgraphics-sfml.so
Then I just added all the directories of /usr/lib/SFML and /usr/lib/SFML16 to ldconfig:
sudo ldconfig /usr/lib/SFML16
You have to do ldconfig every time you switch, so I added it to the script.
If you want the code I have attached the script and test code, compile with...:
g++ -std=c++11 -L /usr/lib/SFML test21.cpp -lsfml-graphics -lsfml-window -lsfml-system
and...
g++ -std=c++11 -L /usr/lib/SFML test16.cpp -lsfml-graphics -lsfml-window -lsfml-system
You can use the script if you put it in /usr/local/bin/sfml_change, and make a link to the bin folder via:
ln -s /usr/local/bin/sfml_change/chsfml.sh /usr/bin/chsfml
So you can run it any time from the command line, to use the script...
Change to SFML 2.1:
chsfml -sfml21
Change to SFML 1.6:
chsfml -sfml16
Clean all links:
chsfml -clean
Help:
chsfml -h
Errors happen every time complaining about symbolic links, unless it does not work (test it first), ignore them.
The files should be set up like so...
SFML library files (taken OUT of the original folders i.e /usr/lib/SFML16/libgraphics-sfml.so.1.6) should go into
/usr/lib/SFML16
/usr/lib/SFML21
SFML header files should go into (taken OUT of original folders, i.e /usr/include/SFMLInclude/SFML16/Graphics.hpp):
/usr/include/SFMLInclude/SFML16
/usr/include/SFMLInclude/SFML21
I might throw this up on github, Il post a link if I do :)
I hope this helps someone! Peace! :-D