獲取方式
官網下載合適版本:https://www.boost.org/
此處用的是boost_1_75_0
版本
開發環境
推薦使用GCC 7.x.x
或以上編譯器
安裝Boost庫
此處採用簡易安裝,預設安裝在/usr/local/include
和/usr/local/lib
下
# 解壓
tar -zxvf boost_1_75_0.tar.gz
# 配置
./bootstrap.sh
# 安裝
./b2 install
安裝驗證
編寫一個boost程式,驗證安裝是否成功
#include <iostream>
#include <boost/version.hpp>
#include <boost/config.hpp>
using std::cout;
using std::endl;
int main(int argc, char * argv[])
{
cout << BOOST_VERSION << endl;
cout << BOOST_LIB_VERSION << endl;
cout << BOOST_PLATFORM << endl;
cout << BOOST_COMPILER << endl;
cout << BOOST_STDLIB << endl;
}
編譯
g++ -o main main.cpp
執行結果
$ ./main
107500
1_75
linux
GNU C++ version 7.3.1 20180303 (Red Hat 7.3.1-5)
GNU libstdc++ version 20180303