1. 首先从网站 http://www.boost.org/ 下载 boost 库
2.1 .安装附加依赖库
- sudo apt-get install build-essential g++ python-dev autotools-dev libicu-dev build-essential libbz2-dev libboost-all-dev
2.2 运行脚本文件,--prefix参数,可以指定安装路径,如果不带--prefix参数的话(推荐),默认路径是 /usr/local/include 和 /usr/local/lib,分别存放头文件和各种库。执行完成后,会生成bjam,已经存在的脚本将会被自动备份。
- ./bootstrap.sh --prefix=/usr/local
2.3 安装boost,也就是将头文件和生成的库,放到指定的路径(--prefix)下
- ./b2 install --prefix=PREFIX where PREFIX is a directory where you want Boost.Build to be installed.
2.4 测试是否安装成功 ,建立一个boost_test.cpp 文件
2.5 编辑boost_test.cpp 文件
- #include <iostream>
- #include <boost/array.hpp>
-
- using namespace std;
- int main(){
- boost::array<int, 4> arr = {{1,2,3,4}};
- cout << "hi" << arr[0]<<endl;
- return 0;
- }
- #include <iostream>
- #include <boost/array.hpp>
-
- using namespace std;
- int main(){
- boost::array<int, 4> arr = {{1,2,3,4}};
- cout << "hi" << arr[0]<<endl;
- return 0;
- }