Boost logo

Boost Users :

Subject: [Boost-users] MacOSX: problems linking with "universal binary" Boost and libstdc++-static.a
From: FFT (fft1976_at_[hidden])
Date: 2009-03-28 17:03:54


I'm trying to link my "universal binary" program statically with both
Boost and libstdc++-static.a to make the distribution easier, because,
as I understand, /usr/lib/libstdc++.6.dylib isn't always there,
especially, in versions prior to OSX-10.4

I can build Boost apparently successfully, but linking the regex
example statically with libstdc++ causes errors. Perhaps someone here
could point out what I'm doing wrong (if anything).

Here's what I did to build "universal binary" Boost and compile the
example (Btw, the documentation could use some clarity about the
recipe):

(1) Make sure "g++ --version" says i686-apple-darwin8-g++-4.0.1
(symlinks and PATH adjustments to avoid v3.3)

(2) ../../bjam --prefix=~/local --build-dir=~/boost_build
toolset=darwin link=static \
 threading=multi architecture=combined stage install

(I also tried adding runtime-link=static with similar results, see below)

(3) g++ -static-libgcc -I ~/local/include/boost-1_38 example.cpp \
-o example /usr/lib/libstdc++-static.a ~/local/lib/libboost_regex-xgcc40-mt.a

(I tried skipping /usr/lib/libstdc++-static.a, in which case the
binary builds, but is linked with
/usr/lib/libstdc++.6.dylib)

The errors I get here take up many pages and start like this:

/usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: warning multiple
definitions of symbol std::codecvt<char, char,
__mbstate_t>::~codecvt()
/usr/lib/libstdc++-static.a(codecvt.o) private external definition of
std::codecvt<char, char, __mbstate_t>::~codecvt()in section
(__TEXT,__tex
t)
/usr/lib/gcc/i686-apple-darwin8/4.0.1/libstdc++.dylib(single module)
definition of std::codecvt<char, char, __mbstate_t>::~codecvt()
/usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: warning multiple
definitions of symbol std::codecvt<char, char,
__mbstate_t>::~codecvt()
/usr/lib/libstdc++-static.a(codecvt.o) private external definition of
std::codecvt<char, char, __mbstate_t>::~codecvt()in section
(__TEXT,__tex
t)
/usr/lib/gcc/i686-apple-darwin8/4.0.1/libstdc++.dylib(single module)
definition of std::codecvt<char, char, __mbstate_t>::~codecvt()

When I use Boost built with "runtime-link=static", the errors look
like this instead:

/usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: warning multiple
definitions of symbol std::codecvt<char, char,
__mbstate_t>::~codecvt()
/usr/lib/libstdc++-static.a(codecvt.o) private external definition of
std::codecvt<char, char, __mbstate_t>::~codecvt()in section
(__TEXT,__tex
t)
/usr/lib/gcc/i686-apple-darwin8/4.0.1/libstdc++.dylib(single module)
definition of std::codecvt<char, char, __mbstate_t>::~codecvt()
/usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: warning multiple
definitions of symbol std::codecvt<char, char,
__mbstate_t>::~codecvt()
/usr/lib/libstdc++-static.a(codecvt.o) private external definition of
std::codecvt<char, char, __mbstate_t>::~codecvt()in section
(__TEXT,__tex
t)

Any suggestions?


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