如何在 OSX 中安装 boost
How to install boost in OSX
我以前做过的事情:
(1) 下载.tar
(2) 解压缩
(3) 光盘到路径
(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 命令中添加包含路径的位置(这是头文件所在的位置)。通常,编译命令需要具有包含路径,并且类似于以下内容:
g++ -I/usr/local/include test.cpp
但是,上面的标准包含路径位置可能不是正确的位置,因为在步骤 (5) 中:
应将以下目录添加到编译器包含路径中:
/用户/绿智107/下载/boost_1_57_0
因此,在这种情况下,您可能会使用:
g++ -I/Users/lvzhi107/Downloads/boost_1_57_0 test.cpp
如果您再次遇到相同的错误,则可能建议退后一步并更深入地阅读文档,或者使用其他安装boost的方法,例如MacPorts。
相关文章:
- C++:如何在CLion IDE中安装Boost
- 如何在 Mac OS 上安装 boost-mpi 及其对 clang 的依赖关系?
- 在 Windows 10 上安装 Boost 时遇到问题
- 无法在 OS X Sierra 上安装 boost
- boost_signals 使用 brew 安装 boost 时缺少库
- 我是否需要安装Boost来构建odeint
- 非相互互动安装Boost二进制
- 如何在Ubuntu中安装Boost多重任库
- 在Windows 8.1上安装Boost Python,正确设置工具链
- 如何在我的mac上安装boost
- 在macosx上安装boost和PyUblas时出错
- 使用单独的Boost库进行编译,无需安装Boost
- 在 Ubuntu 12.04 中编译并安装 Boost 1.34.1
- 如何在 OSX 中安装 boost
- 安装 boost 会搞砸我的程序吗?
- 从源代码编译后未安装 Boost ptr_container库
- 在 debian 中安装 boost(用于代码块)
- 无法成功安装 Boost.Python
- 在 Mac 上安装 Boost with CodeBlocks
- <dir> 因缺乏而跳过...尝试在 Ubuntu 1.49 上安装 Boost 11.04 时出错