SFML community forums
Help => General => Topic started by: Xylankant on June 28, 2008, 01:00:49 am
-
Hey folks!
I've just stumbled upon a problem using SFML under Linux (as Cross Compiling binaries for Linux is quite non-trivial under WinXP ^^ ).
Problem is: I can't figure out a way of statically linking the libraries.
g++ -c main.cpp
g++ -o main main.o -static lsfml-system
will give me an error saying
/usr/bin/ld: cannot find lsfml-system
When I try compiling without the -static option, everything works fine, however I'd have a dynamic link
I have as well tried -Wl,-static and -Wl,-Bstatic, all's the same result...
System is Ubuntu 8.04
SFML is 1.3
Is there a way to solve this problem?
-
The way it works in MinGW is you just links the libraries that have "-s" in their name. You do not need to use "-static".
EDIT: Does a dynamically linked version of SFML even exist for Linux?
Have you tried just doing this?
g++ -c main.cpp
g++ -o main main.o -lsfml-system
The error "/usr/bin/ld: cannot find lsfml-system" makes me think you don't have the correct syntax for g++.
After a little time on google, I found examples of people using syntax like this to statically link libraries:
-static-libsfml-system
-
Have you tried just doing this?
g++ -c main.cpp
g++ -o main main.o -lsfml-system
The error "/usr/bin/ld: cannot find lsfml-system" makes me think you don't have the correct syntax for g++.
Yap, I wrote above that, without the -static option, I'm fine with compiling ;)
After a little time on google, I found examples of people using syntax like this to statically link libraries:
-static-libsfml-system
thanks, I'll try it and report on that!
-
Ok, that doesn't work :)
But thanks anyway...
P.S.: Syntax doesn't seem to matter that much, as for what I found out was people writing the same options down to different positions, doing the same, however, compiling with
g++ -c [filename] [options]
g++ -o [output file] [input file] [options]
should always work...and it does with sfml, as well, when not linking statically
-
SFML libraries under Linux are dynamic only, the static ones are not provided.
-
SFML libraries under Linux are dynamic only, the static ones are not provided.
OK, thank you.
Good to known, now I can stop searching a way to link statically :)
So, what to do when "shipping" my program to a friend of mine, who doesn't have sfml installed to his system?
Does he have to install sfml, or is shipping the -lsfml-xxx.so.1 right with my program enough?
-
The best solution is to install SFML on your friend's computer (this can be done by a script provided with your program), which is just copying the libraries and creating the proper symbolic links.
-
Ok, thank you very much, Laurent.
I have to admitt, I don't known how to do that right now, but I'm going to find out (I'm new to Linux programming ^^).
So far, my friend is willing to install sfml by himself (good luck for me ;) )
-
Installing SFML is just copying the libraries (all the *.so.1) to either /usr/lib or /usr/local/lib, and creating the symbolic links libsfml-xxx-.so pointing to libsfml-xxx-.so.1.
Take a look at the "install" target of the makefiles for the corresponding commands.
-
Thanks again, I'm going to work through that!
-
Installing SFML is just copying the libraries (all the *.so.1) to either /usr/lib or /usr/local/lib, and creating the symbolic links libsfml-xxx-.so pointing to libsfml-xxx-.so.1.
Take a look at the "install" target of the makefiles for the corresponding commands.
sorry for ressurecting an old thread but I have a question on this...
what about if I build it in my pc and want to test it in University pcs with no root acess? (not possible to enter in usr folder)
impossible?
-
Yes, install it wherever you want (like /home/you/sfml) and setup your compiler, linker and library loader to know about this particular path.
-
and setup your compiler, linker and library loader to know about this particular path.
that would require root access right?
-
Nop.