Boost logo

Boost :

Subject: Re: [boost] building a run-time static version
From: Vladimir Prus (vladimir_at_[hidden])
Date: 2009-08-18 16:04:57

Lorenzo Bettini wrote:

> Vladimir Prus wrote:
>> Lorenzo Bettini wrote:
>>> Hi
>>> I was trying to build a static version of the regex library (boost
>>> 1.39), issuing this command:
>>> ./bjam --build-dir=build_static --layout=system threading=single
>>> runtime-link=static link=static
>>> but I always get this error:
>>> error: link=shared together with runtime-link=static is not allowed
>>> error: such property combination is either impossible
>>> error: or too dangerious to be of any use
>>> but why is it trying to use link=shared when I explicitly specified
>>> link=static?
>> You must have an ICU installed, and Boost.Regex tries to use that automatically.
>> ICU only comes as shared library. You might wish to remove the ICU_PATH
>> setting in project-config.jam or whenever it's is made.
> Hi
> I removed the ICU reference from the project-config.jam, and managed to
> build the library; however when I statically link to boost regex
> library, I get
> libtool: link: g++ -g -O2 -static -o check-regexp check-regexp_cmd.o
> check-regexp.o -L/opt/boost/lib -lboost_regex-gcc43-mt-1_39
> ../gl/.libs/libgnu.a
> /opt/boost/lib/libboost_regex-gcc43-mt-1_39.a(static_mutex.o): In
> function `boost::scoped_static_mutex_lock::unlock()':
> static_mutex.cpp:(.text+0x16): undefined reference to `pthread_mutex_unlock'
> /opt/boost/lib/libboost_regex-gcc43-mt-1_39.a(static_mutex.o): In
> function `boost::scoped_static_mutex_lock::lock()':
> thus the library was not linked with runtime-link=static, was it?

I don't think this conclusion is right -- nothing above suggests any
dependency on any shared library. Rather, the errors above mean
that you have:

1. Failed to linked with boost.thread library
2. Failed to pass -pthreads to the compiler

> Or at
> least, it builds a multi-threaded version while I requested, with
> threading=single a single threaded version...

To begin with, you are requesting multithreaded library:


Here, "mt" stands for multithreaded. Then, it's is fairly unlikely
that such a library would be produced if you say threading=single.
I would guess that -L/opt/boost/lib has something you previously
installed, and if you run:

 ./bjam --build-dir=build_static --layout=system threading=single
  runtime-link=static link=static

it puts new libraries in stage/lib. Did you copy non-MT versions
to /opt/boost/lib? If so, you should be using -l option without "mt".

> I actually need to build
> a static version of boost which does not depend on any other dynamic
> library (because, in turn, I need to build a completely static binary
> that uses boost)... where am I going wrong?

Hopefully the above explains this?

- Volodya

Boost list run by bdawes at, gregod at, cpdaniel at, john at