brew 方式安裝
-
安裝命令
brew install boost
-
安裝位置
tannzh-mac:~ tannzh$ brew install boost ==> Downloading https://homebrew.bintray.com/bottles/boost-1.68.0.mojave.bottle. ######################################################################## 100.0% ==> Pouring boost-1.68.0.mojave.bottle.tar.gz 🍺 /usr/local/Cellar/boost/1.68.0: 13,712 files, 460.2MB
所以最終頭文件目錄:/usr/local/Cellar/boost/1.68.0/include
lib目錄:/usr/local/Cellar/boost/1.68.0/lib
源碼安裝
-
從boost官網下載最新boost庫源碼,目前最新版本爲boost 1.68.0
-
解壓源文件
-
配置安裝
1. 執行./bootstrap.sh 就行安裝配置 2. sudo ./b2 --buildtype=complete install ###進行所有庫的安裝,安裝路徑爲/usr/local/include/boost, 庫的路徑爲/usr/local/lib
-
構建工具安裝
cd tools/build ./booststrap.sh sudo ./b2 install
測試
-
使用Clion測試
# 添加boost頭文件搜索路徑 include_directories(/usr/local/Cellar/boost/1.68.0/include) # 添加boost庫文件搜索路徑 link_directories(/usr/local/Cellar/boost/1.68.0/lib)
-
測試代碼1
// // Created by tannzh on 2018/12/3. // #include <iostream> #include <boost/timer.hpp> void boost_test1() { boost::timer tm; std::cout << tm.elapsed() << std::endl; } int main() { boost_test1(); return 0; }