Barth
Barth

Reputation: 15775

How can I specify that library X must be linked statically?

I have a piece of software which is linked against several libraries. They all exists in a dynamic (.so) and a static (.a) version. By default, when using g++ it chooses the dynamic version of the libraries and that's fine with me.

However, one of them absolutely needs to be linked statically. I thought about using -static but then it uses a static version for all of them, which is not what I want.

How can I specify that library X must be linked statically, while the others continue to be linked against the shared version of the libs ?

Upvotes: 8

Views: 867

Answers (1)

Jack
Jack

Reputation:

g++ -o foo (foo-objects) -Wl,-Bstatic -lmustbestatic -Wl,-Bdynamic -lother-lib

Upvotes: 9

Related Questions