Boost logo

Boost Users :

From: me22 (me22.ca_at_[hidden])
Date: 2006-12-21 11:39:19


On 12/20/06, Bo Peng <ben.bob_at_[hidden]> wrote:
> $ g++ -static -lboost_iostreams -lz -lbz2 test.cpp
> fails, and
>
> $ g++ -static test.cpp -lboost_iostreams -lz -lbz2
> succeeds. Why did
>
> $ g++ -shared -lboost_iostream -lz -lbz2 test.cpp
> succeed is beyond me.
>
When you use static libraries, only the symbols you need are taken
from the static libraries. In the first command line, it performs
that process before compiling test.cpp, so no symbols are needed, so
none are taken. In the second, it compiles test.cpp first so it knows
which symbols you need from the static libraries. For the third case,
linking to shared libraries doesn't only take the symbols needed, for
obvious reasons, so all the symbols you need (and those you don't) are
defined before test.cpp gets compiled.

~ Scott McMurray


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