Boost Mac运行

1,install Boost

sudo brew install boost

2, Copy boost 到用户目录下 /Users/xxx/

sudo cp -r /usr/local/Cellar/boost/1.58.0 /Users/xxx/

3, 新建Xcode command line project

4,更改project setting

https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/ConfiguringYourApp/ConfiguringYourApp.html

添加Search Header和Lib Path

 

另外的博客的引用

  1. 打开Xcode,新建一个工程,【OS X】-》【Application】-》【Command Line Tool】,创建此类工程。
  2. 将此预编译指令加入main文件中测试#include <boost/asio.hpp>,会发现头文件找不到。这是因为新建的工程没有配置为使用boost库。此时我们需要点击【项目工程文件】-》【Targets】-》【BuildSetting】-》【Search Paths】-》【Header Search Paths】,输入/opt/local/include,这样头文件能找到,再添加库文件搜索路径,再【Search Paths】-》【Library Search Paths】,输入/opt/local/lib。
  3. 上面添加了头文件和库文件搜索目录后,点击运行,仍然无法通过编译,我这边是弹出错误,undefined reference to `boost::system::system_category(),这可能是连接不到对应的库,点击【项目工程文件】-》【Targets】-》【Build Phases】-》【Link Binary with Libraries】,点击下侧的+号,添加libboost_system.a,点击Add Another...,到/opt/local/lib中选择libboost_system-mt.a,在次点击下侧的+号,添加libboost_filesystem.a,点击Add Another...,到/opt/local/lib中选择libboost_filesystem-mt.a,这样就添加两个库文件。
posted @ 2017-05-24 20:45  AnAn2017  阅读(618)  评论(0编辑  收藏  举报