安装boost
这里先确保boost库安装成功,能正常使用。
Mac下安装boost库有两种方式,编译源码和homebrew。
不知什么原因,手动编译源码失败:
...failed darwin.compile.c++
...failed updating 432 targets...
...skipped 334 targets...
...updated 31 targets...
所以推荐使用homebrew的方式,include文件、lib文件一步到位:
brew install boost
默认安装位置是/usr/local/Cellar/boost/1.72.0
验证boost
下面测试boost环境是否正确搭建。
新建一个xcode命令行项目,点项目文件进入配置页面:

在header search paths里添加/usr/local/Cellar/boost/1.72.0/include:

不包含库的例子
main.cpp里写如下测试代码:
#include <iostream>
#include <boost/lambda/lambda.hpp>

本文介绍了在Mac环境下如何使用Xcode配置boost库来编写C++程序。通过homebrew安装boost库,并提供了不包含库和包含库的代码例子,指导读者验证boost环境是否正确搭建。在Xcode项目配置中,调整Header Search Paths,并在必要时添加Other Linker Flags以链接boost库。
最低0.47元/天 解锁文章
5592

被折叠的 条评论
为什么被折叠?



