I would like to compile boost for Mac OS X 10.9, with stdlibc++. I run the following command:
./b2 threading=multi link=static runtime-link=static cxxflags="-stdlib=libstdc++" linkflags="-stdlib=libstdc++"
The build completes successfully; however, my application build fails at linkage time, when it can't find symbols suck as std::__1::locale::use_facet, std::__1::basic_string etc. The pertinent detail there is the __1, I believe.
My question is, how do I compile boost for OSX 64b platforms with stdlibc++?
More info:
I have noticed the following logs during compilation:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: bin.v2/libs/filesystem/build/clang-darwin-4.2.1/release/link-static/runtime-link-static/threading-multi/libboost_filesystem.a(windows_file_codecvt.o) has no symbols
I use an easy command line to do the trick found on boost mailing list: http://lists.boost.org/boost-users/2014/02/81274.php
this is the snippet in case the link doesn't work anymore:
Downloaded Boost 1.55, bootstrapped using:
Built using:
Yields in
libboost_chrono.a
:Which implies that the library was built with the option
-stdlib=libstdc++
- i.e. it's linked against the gnu version of the C++ runtime.We purge the build using:
If we don't do that then it doesn't rebuild, and you end up with the same code as before. Next we build using:
Yields in
libboost_chrono.a
:Which implies that it's built against
libc++
.This can be verified by using a simple test c++ program (to indicate the linking):
so yes, it's compiling with the relevant flag. What it does indicate that you have to pass the
-stdlib=libstdc++
to everything you're compiling if you're using XCode 5 as it now defaults to using-stdlib=libc++
. This means that any C++ based libraries that depend onc++
stdlib that you depend on also have to be compiled with the same flag.Be careful with an incremental build of boost - if you don't purge the
.o
and.a
files, they don't get recompiled based on the changed flags, which keeps the files as compiled, so if they were miscompiled then you encounter the problem.