Boost logo

Boost Users :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2007-07-17 15:00:40


Niko Vuokko wrote:

> I know there are some messages on this subject, but none of them gave me
> the answer or then I just didn't understand it. I'm trying to link some
> boost libraries statically to my program, but at the same time link the
> standard libraries dynamically. I have little experience ( == a total
> noob) in the linking process. I'm using ld version 2.16.1 and g++ version
> 4.1.2 on Linux. My /usr/lib has files like
>
> libboost_regex.so
> libboost_regex-s.a
> (the same for multi-threaded progs)
>
> Actually I'm unable even to link everything statically:
>
> ld <obj-files> -Bstatic -lboost_filesystem-s -lboost_program_options-s
> -lboost_regex-s -o prog

You better avoid calling ld directly, unless you're certified ld guru.
Use g++ instead.

> fails.

Since you failed to provide the error message, the above is all I can
suggest.

> Also trying to link runtime dynamically with
>
> ld <obj-files> -Bstatic -lboost_filesystem-s -lboost_program_options-s
> -lboost_regex-s -Bdynamic -o prog
>
> fails.

First, you fail to provide the error message again. Second,
which manual say that using trailing -Bdynamic works? Further, with
explicit '-lboost_filesystem-s' you don't need -Bstatic.

> I also tried to ar/ranlib the so object files into .a archives

That will never work. .a archives can technically contain anything
from .o to .jpg, but only .o will be used by linker.

So: (1) use gcc/g++, not ld and (2) provide the real error message.

- Volodya


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net