c++ - How to choose between shared and static library? -


i'm trying run standard example sfml library in linux. have download rep. github, build , install cmake. have build 2 libraries static/shared debug, , 2 libraries static/shared release.

the problem now, don't know compiling in terminal. use commands found on sfml website:

g++ -c test.cpp

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

that works. can run sfml application ./sfml-app , double-click. other people (who have not installed sfml) using linux cant. , think it's because compiler not use static libraries. of course - how could? it's not written in command. don't know how write it.

the name of static-release libraries example

libsfml-graphics-s.a

libsfml-window-s.a

libsfml-system-s.a

what must write in g++, using libs when link stuff?

to link program against static versions of libraries, following:

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

(assuming, of course, these files in local directory.)


Comments