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 ...


5. Use Makefile but not Xcode

Using  clang++  -stdlib=libc++ instead of g++


中文:

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

如果是使用Makefile编译而不是XCode,那么使用clang++  -stdlib=libc++替换g++即可


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值