SFML community forums
Help => General => Topic started by: Chi on July 15, 2013, 07:15:08 pm
-
Hello all,
i have create static libarys for Linux by this Tutorial in Cmake: http://sfmlcoder.wordpress.com/2011/08/16/building-sfml-2-0-with-make-for-gcc/ Now i have compiled my test app with this tutorial: http://www.sfml-dev.org/tutorials/2.0/start-linux.php
My Question:
Other Poeple cant start my compiled sfml-app. I think, its because this ways does not use the static linked libarys. But how can i make that?
Thank you for help :) !
-
You must link the dependencies of SFML. When you create a static library no linking is done, it's left to the final binary.
-
You must link the dependencies of SFML. When you create a static library no linking is done, it's left to the final binary.
Hello Laurent, thanks for your fast answer.
I want to choose now the way without an IDE. It works. But i have another Problem, that other poeple using Linux cant start my sfml-app. (I have edit my first post and describe it). How can use the static libarys for compiling?
best regards
-
other poeple using Linux cant start my sfml-app
More details would be welcome.
-
More details would be welcome.
i compiling like this:
g++ -c test.cpp -I /home/brause/dev/include
g++ test.o -o sfml-app -L /home/brause/dev/lib -lsfml-graphics -lsfml-window -lsfml-system
when they start ./sfml-app , they get the message:
"command not found".
but i can start the sfml-app by ./sfml-app or also doppelclick. This:
export LD_LIBRARY_PATH=<sfml-install-path>/lib && ./sfml-app
is not need, dont know why.
-
I don't know, sorry. They probably do something wrong but I don't know what.
-
Why they do something wrong? I Think i dont have compiled with the static libarys?
Because on the website you write this:
If SFML is not installed in a standard path, you need to tell the library loader where to find the SFML libraries first:
export LD_LIBRARY_PATH=<sfml-install-path>/lib && ./sfml-app
Of course they didnt have installed sfml. I want to compile it like that they dont need to install :o ?
-
ok - i try to ask on another way.
How can i choose when i compilng:
g++ test.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system
wich libarys are used static/shared/debug/release ?
-
Why they do something wrong?
I said "probably". Because it works for you and not for them, and because of the error message too. "Command not found" means that what they type doesn't exist; a missing dependency would trigger another error ("Failed to find shared library xxx.so" or something).
How can i choose when i compilng:
g++ test.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system
wich libarys are used static/shared/debug/release ?
Everything is explained in the "Getting started" tutorial.
-
when they start ./sfml-app , they get the message:
"command not found".
They need to make sure, that the sfml-app has the correct permissions, especially the one for execution.
Btw. it's still recommended to link shared on Linux and simply provide the needed libraries in a separated directory and then create a shell script that adds the path of the library to LD_LIBRARY_PATH. ;)
-
`gcc -static ...` tries to link everything statically... which is baaaad. So distros go out of their way to make it imposible.
If you want to link some stuff statically, you should just link their .o files, from the SFML compilation. Or, bettter, use libtool to make a libsfml-*-.la, which is actually just a description of what to link, and "link" that.
EDIT: Just to make this clear, it would be e.g.:
gcc -lstdc++ -o my-app my-app.cc smfl-source-dir/Display.o smfl-source-dir/Mouse.o...
If you add -lsfml-* in there it will still try to dynamically link, of course.
-
Thank you for all your answers! I try to figure out your suggestions about sharing shared linked binarys. But there is one thing i still not understand.
Laurent wrote its explained in the getting started tutorial. Maybe i dont understand what he write their, but iam still confused about the compiler command:
-lsfml-graphics -lsfml-window -lsfml-system
how the g++ knows about wich libarys is used? Or better say: How i know wich libary is used? What is happening with this command? Because i have create 4 libarys for static/shared debug/release. My folder /usr/local/lib$ ls looks like this:
libsfml-audio-d.so libsfml-graphics.so.2.0 libsfml-system.so.2
libsfml-audio-d.so.2 libsfml-network-d.so libsfml-system.so.2.0
libsfml-audio-d.so.2.0 libsfml-network-d.so.2 libsfml-window-d.so
libsfml-audio-s.a libsfml-network-d.so.2.0 libsfml-window-d.so.2
libsfml-audio-s-d.a libsfml-network-s.a libsfml-window-d.so.2.0
libsfml-audio.so libsfml-network-s-d.a libsfml-window-s.a
libsfml-audio.so.2 libsfml-network.so libsfml-window-s-d.a
libsfml-audio.so.2.0 libsfml-network.so.2 libsfml-window.so
libsfml-graphics-d.so libsfml-network.so.2.0 libsfml-window.so.2
libsfml-graphics-d.so.2 libsfml-system-d.so libsfml-window.so.2.0
libsfml-graphics-d.so.2.0 libsfml-system-d.so.2 pkgconfig
libsfml-graphics-s.a libsfml-system-d.so.2.0 python2.7
libsfml-graphics-s-d.a libsfml-system-s.a python3.3
libsfml-graphics.so libsfml-system-s-d.a
libsfml-graphics.so.2 libsfml-system.so
And their is no libary called "-lsfml-graphics" . When i use this command, wich libary is in use? the libsfml-graphics-d.so or the libsfml-graphics.so ? Or is this depends by commands i give the compiler . For example:
-lsfml-graphics -lsfml-window -lsfml-system -> compiling the release binarys
-g -lsfml-graphics -lsfml-window -lsfml-system -> compiling the debug binarys
? Or did i missunderstand here something totally?
best regards :) !
-
-lsfml-graphics will make ld search the library path (usually /usr/local/lib and /usr/lib and /lib among others) for libsfml-graphics.so (which should be a link to libsfml-graphics.so.2 which in turn should be a link to libsfml-graphics.so.2.0). To use the debug version you'd use -lsfml-graphics-d - so you do have to specify. This is not necessary when using a build system like cmake which will select the libraries necessary depending on the kind of build you've asked it to produce (if you write the CMakeLists.txt correctly.)
-
Ah okey :) Thank you !