Reputation: 33
I have a libSomelib.a that can be linked to an executable by the following command:
g++ -L. -lsomeLib -lpcrecpp -lpcre -lpthread main.cpp -o main
But how could I link a shared object from it, that contains all depentencies?
I want to achieve the following with my new someLib.so:
g++ -L. -lsomeLib main.cpp -o main
I have tried the following:
g++ -shared -L. -lsomeLib -lpcrecpp -lpcre -lpthread -o libSomelib_static.so
This gives me an .so file with no symbols.
PS: I'm completely beginer of compilers.
Upvotes: 0
Views: 4774
Reputation: 136266
There are a few issues at play here:
g++ -o main -pthread main.cpp -L. -lsomeLib -lpcrecpp -lpcre
.-fPIC
compiler flag). Archives are normally built without this flag.-pthread
flag both when compiling and linking multi-threaded applications, not -lpthread
.Upvotes: 2