XCode5/Apple LLVM 5.0停使用boost的方法

XCode5/Apple LLVM 5.0下使用boost的方法

Because Apple changes the compiler to llvm only in XCode5, so there are some compatible problems with the boost library compiled by old gcc , I tried several days, and get the result, we must set the compiler to clang.

1. download newest boost sourcecode from http://sourceforge.net/projects/boost/files/boost/1.54.0/


2. use tar to uncompress it, then execute ./bootstrap.sh --prefix=/Users/dotphoenix/Public/boost toolset=clang

we set the install path to /Users/dotphoenix/Public/boost , changes it to yours, the very important is set compiler to clang


3. ./b2 toolset=clang --without-mpi cxxflags="-arch i386 -arch x86_64 -fvisibility=hidden -fvisibility-inlines-hidden -std=c++11 -stdlib=libc++ -ftemplate-depth=512" linkflags="-stdlib=libc++" link=static stage install


the static libraries are installed at /Users/dotphoenix/Public/boost/lib, and the headers are installed at /Users/dotphoenix/Public/boost/include


4. add the library path and the header path at Build Settings->Search Paths, then Add files to ...


中文:

因为XCode5 完全切换到了LLVM,丢弃了GCC,所以使用旧版本GCC编译的boost库会出现load library的错误(dylib/dlopen???不是太明白原因),所以必须使用LLVM重新编译库,最好是编译成静态的,上面的步骤就是做这个事情的。