This is the mail archive of the
mailing list for the GCC project.
Re: selective static linking
- From: Kai Ruottu <kai dot ruottu at wippies dot com>
- To: Marian Ciobanu <ciobi at inbox dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 26 Oct 2009 14:11:54 +0200
- Subject: Re: selective static linking
- References: <403024653A4.000002A3ciobi@inbox.com>
Marian Ciobanu wrote:
When building an executable on Linux I'd like to link statically a particular library, namely Boost Serialization, while keeping the other libraries linked dynamically. Both libboost_serialization.a and libboost_serializationso exist. I tried to play with the -l parameter, passing the actual file name or including the full path, but these didn't help.
Well, I have a workaround: rename libboost_serialization.a as libyyy.a and then use -lyyy instead of -lboost_serialization ; however, I wonder what the real solution is.
What about opening the GNU manual(s) ?
Maybe you have already done this with the GCC one but that is wrong
manual for this problem :(
GCC gives some options to the linker as default, others one should
decide oneself. There is that
GCC-option '-Wl,<linker_option(s)>' for this "giving extra options for
the linker ('ld')" purpose.
In order to learn those linker options one needs the GNU 'ld' manual !
Somewhere there should be printable PDF-versions for the GNU manuals, I
could now find
only the online HTML-manuals for binutils, the 'ld' options could be
found via :
Ok, the '-Bstatic' and '-Bdynamic' options would be for this, "wrapping"
with these, in your case :
... -Wl,-Bstatic -llibboost_serialization -Wl,-Bdynamic ....
meaning "switch static linking on", link against the static version,
"return back to shared defaults"....