Moep Meep Moep Meep - 1 year ago 95
Linux Question

How to choose between shared and static library?

I'm trying to run the standard example from the SFML Library in Linux. I have download the Rep. from Github, build and install it with CMake. I have build 2 Libraries for static/shared debug, and 2 Libraries for static/shared Release.

The problem now, I don't know much about compiling in the Terminal. I use the commands I found on the SFML Website:

g++ -c test.cpp

g++ test.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system

that works. I can run my SFML Application by ./sfml-app and double-click. But other people who (who have not installed SFML) using Linux cant. And I think it's because the compiler does not use the static libraries. Of course - how he could? It's not written in the command. But I also don't know how to write it.

The name of the static-release libraries is for example




what must I write in g++, that he is using this libs when he link the stuff?

Answer Source

To link your program against the static versions of the libraries, you would do the following:

g++ test.o -o sfml-app libsfml-graphics-s.a libsfml-window-s.a libsfml-system-s.a

(Assuming, of course, that these files are in your local directory.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download