[英]How to install boost in OSX
我之前做过的事情:
(1)下载.tar
(2)解压缩
(3)cd到路径
(4)./bootstrap.sh
(5)等到:
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/Users/lvzhi107/Downloads/boost_1_57_0
The following directory should be added to linker library paths:
/Users/lvzhi107/Downloads/boost_1_57_0/stage/lib
(6)./ b2安装
但它显示:
...failed common.copy /usr/local/lib/libboost_wave.a...
...failed updating 65 targets...
...skipped 11349 targets...
然后我写了一个代码: test.cpp
#include<iostream>
#include<boost/format.hpp>
int main()
{
boost::format("hello world");
}
使用g ++: g++ test.cpp
运行它,但仍然错误:
test.cpp:2:9: fatal error: 'boost/format.hpp' file not found
#include<boost/format.hpp>
^
1 error generated.
您能告诉我如何解决吗?
您需要在compile命令中添加include路径的位置(这是头文件所在的位置)。 通常,compile命令需要包含路径,并且类似于以下内容:
g++ -I/usr/local/include test.cpp
但是,由于在步骤(5)上,上述标准包含路径位置可能不是正确的位置:
以下目录应添加到编译器包含路径:
/用户/ lvzhi107 /下载/ boost_1_57_0
因此,在这种情况下,您可能会使用:
g++ -I/Users/lvzhi107/Downloads/boost_1_57_0 test.cpp
如果再次遇到相同的错误,建议您退一步并更深入地阅读文档,或者使用其他安装Boost的方法,例如MacPorts。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.