How to compile boost for OS X 64b platforms using stdlibC ++?

I would like to compile boost for Mac OS X 10.9 using stdlibC ++. I run the following command:

./b2 threading=multi link=static runtime-link=static cxxflags="-stdlib=libstdc++" linkflags="-stdlib=libstdc++" 

Build completed successfully; however, my application build does not work during binding, when it cannot find the characters to suck like std :: __ 1 :: locale :: use_facet, std :: __ 1 :: basic_string, etc. The relevant detail is __1, I suppose.

My question is: how do I compile boost for OSX 64b platforms using stdlibC ++?

Additional Information:

During compilation, I noticed the following logs:

/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 characters

+8
c ++ boost clang libstdc ++ macos
source share
2 answers

Downloaded Boost 1.55, loaded using:

 ./bootstrap.sh --prefix=/usr/local/boost155 cxxflags="-arch i386 -arch x86_64" \ address-model=32_64 threading=multi macos-version=10.8 stage 

Built using:

 ./b2 threading=multi link=static runtime-link=static \ cxxflags="-stdlib=libstdc++" linkflags="-stdlib=libstdc++" 

Inferior to libboost_chrono.a :

  U std::string::_Rep::_M_destroy(std::allocator<char> const&) U std::string::_Rep::_S_empty_rep_storage U std::string::append(char const*, unsigned long) U std::string::append(std::string const&) U std::string::assign(char const*, unsigned long) U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) 

This means that the library was built with the option -stdlib=libstdc++ - that is, it is associated with the gnu version of the C ++ runtime.

We clean the assembly using:

 find . -name \*.o -print0 | xargs -0 rm find . -name \*.a -print0 | xargs -0 rm 

If we do not, it will not be restored, and you will receive the same code as before. Then we build with:

 ./b2 threading=multi link=static runtime-link=static \ cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" 

Inferior to libboost_chrono.a :

  U std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(char const*) U std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(char const*, unsigned long) U std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::assign(char const*) U std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) U std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string() 

This means that it is created against libc++ .

This can be verified using a simple C ++ test program (to specify a link):

 #include <string> int main(int argc, char **argv) { std::string s("Hello World"); return 0; } $ make test c++ test.cpp -o test $ nm ./test | c++filt U std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(char const*, unsigned long) U std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string() $ rm test $ make test CXXFLAGS=-stdlib=libstdc++ c++ -stdlib=libstdc++ test.cpp -o test $ nm ./test | c++filt U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() 

so yes, it compiles with the corresponding flag. This means that you must pass -stdlib=libstdc++ to everything you compile if you are using Xcode 5, since now defaults to -stdlib=libc++ . This means that any C ++ libraries dependent on c++ stdlib that you depend on must also be compiled with the same flag.

Be careful with the incremental build of boost - if you do not clear the .o and .a , they will not be recompiled based on the modified flags that save the files as compiled, so if they were compromised, then you run into a problem.

+21
source share

I use a lightweight command line to do the trick found on the boost mailing list: http://lists.boost.org/boost-users/2014/02/81274.php

this is a snippet if the link no longer works:

 $ cd tools/build/v2/ $ ./bootstrap.sh $ cd ~/boost-stdc++-install/boost_1_54_0 $ cd ~/boost-stdc++-install/boost_1_54_0 $ tools/build/v2/b2 \ --build-dir=`pwd`/tmp/build/ \ --stagedir=`pwd`/tmp/stage/ \ --buildid=libstdc++ \ --layout=tagged -j24 \ toolset=clang \ cxxflags="-ftemplate-depth=999 -stdlib=libstdc++" \ linkflags="-stdlib=libstdc++" \ define=BOOST_SYSTEM_NO_DEPRECATED stage 
0
source share

All Articles