views:

155

answers:

1

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 ?

+5  A: 

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

Thanks, it was exactly what I was looking for!
Barth