Marian Ciobanu wrote:
Hi,
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) ?
http://www.gnu.org/manual/manual.html
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 :
http://sourceware.org/binutils/docs/ld/Options.html#Options
Ok, the '-Bstatic' and '-Bdynamic' options would be for this, "wrapping"
the '-l<libname>'
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"....