Boost logo

Boost :

Subject: Re: [boost] building a run-time static version
From: Lorenzo Bettini (bettini_at_[hidden])
Date: 2009-08-19 02:24:20

still problems (please read below)

Vladimir Prus wrote:
>> sudo ./bjam install
>> warning: Building Boost.Regex with the optional Unicode/ICU support
>> disabled.
>> note: Please refer to the Boost.Regex documentation for more information
>> note: this is a strictly optional feature.
>> ...patience...
>> ...found 14569 targets...
>> ...updating 5 targets...
>> common.copy /opt/boost/lib/
>> ln-UNIX /opt/boost/lib/
>> common.copy /opt/boost/lib/libboost_regex-gcc43-mt-1_39.a
>> ln-UNIX /opt/boost/lib/libboost_regex-gcc43-mt.a
>> ln-UNIX /opt/boost/lib/
>> ...updated 5 targets...
>> thus, bjam install seems to install the -mt version, while I requested
>> to build the non threaded version... probably I'm doing something wrong
>> with bjam build/install?
> Unlike autotool, 'install' is not something completely unrelated to
> the regular build process. It's basically an ordinary target, and
> therefore is affected by the properties you specify. You shoul
> be using:
> ./bjam --build-dir=build_static --layout=system threading=single
> runtime-link=static link=static install
> That is, passing all the same options. And, you don't need separate
> build and install steps. The above command will both build and install
> everything necessary.

OK, I see

>> g++ -static -I /opt/boost/include/ regex_use.cpp
>> /opt/boost/lib/libboost_regex.a -o regex_use_static
>> /opt/boost/lib/libboost_regex.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.a(static_mutex.o): In function
>> `boost::scoped_static_mutex_lock::lock()':
>> so is libboost_regex.a still built using multithreading?
> Apparently. Presumably, that's because it was built this way. I would suggest you
> remove both /opt/boost and stage directories and then either:
> 1. Run:
> ./bjam --layout=system threading=single runtime-link=static link=static install
> (Note that I have omitted --build-dir, since it's not really necessary).

I did, and now get the library installed, but, again, I get:

g++ -static regex_use.o -I$HOME/boost/include -L$HOME/boost/lib
-lboost_regex -o regex_use_static
/home/bettini/boost/lib/libboost_regex.a(static_mutex.o): In function
static_mutex.cpp:(.text+0x16): undefined reference to `pthread_mutex_unlock'
/home/bettini/boost/lib/libboost_regex.a(static_mutex.o): In function
/usr/lib/gcc/i486-linux-gnu/4.3.3/libstdc++.a(locale.o): In function
`std::locale::_Impl::_M_install_cache(std::locale::facet const*,
unsigned int)':
undefined reference to `pthread_mutex_lock'

If I do (thus, using the .a file directly)

g++ regex_use.o $HOME/boost/lib/libboost_regex.a -o regex_use_static

I don't get errors, but the binary still uses dynamic libraries:

ldd regex_use_static => (0xb800e000) => /usr/lib/ (0xb7eff000) => /lib/tls/i686/cmov/ (0xb7ed9000) => /lib/ (0xb7ec9000) => /lib/tls/i686/cmov/ (0xb7d66000)
        /lib/ (0xb800f000)

If I add the -static flag to g++ I get the same above errors...
what am I doing wrong?

thanks in advance

Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134     (GNU/Linux User # 158233)

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