Xcode编译boost

来源:互联网 发布:知乎对人们生活的影响 编辑:程序博客网 时间:2024/05/16 05:17

xcode 下使用boost 报如下错误

xcode boost/tokenizer.hpp file not found

原因为mac 下无boost。需手工编译。方法如下:
安装boost:

brew install boost

安装完成后,得到如下目录:

/usr/local/Cellar/boost/1.58.0

修改xcode 项目:
HEADER_SEARCH_PATHS中添加/usr/local/Cellar/boost/1.58.0/include

//:configuration = DebugHEADER_SEARCH_PATHS = $(inherited) /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include /usr/local/Cellar/boost/1.58.0/include//:configuration = ReleaseHEADER_SEARCH_PATHS = $(inherited) /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include /usr/local/Cellar/boost/1.58.0/include//:completeSettings = someHEADER_SEARCH_PATHS

在LIBRARY_SEARCH_PATHS中添加/usr/local/Cellar/boost/1.58.0/lib

//:configuration = DebugLIBRARY_SEARCH_PATHS[arch=*] = /usr/local/Cellar/boost/1.58.0/lib//:configuration = ReleaseLIBRARY_SEARCH_PATHS[arch=*] = /usr/local/Cellar/boost/1.58.0/lib//:completeSettings = someLIBRARY_SEARCH_PATHS

写个main牛刀小试一下:

#include <boost/tokenizer.hpp> #include <string> #include <iostream> int main() {   typedef boost::tokenizer<boost::char_separator<char> > tokenizer;   std::string s = "Boost C++ libraries";   boost::char_separator<char> sep(" ");   tokenizer tok(s, sep);   for (tokenizer::iterator it = tok.begin(); it != tok.end(); ++it)     std::cout << *it << std::endl; } 
0 0
原创粉丝点击