Sunday, February 13, 2011

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 ?

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

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

0 comments:

Post a Comment