1. 程式人生 > 其它 >C++——編譯安裝boost庫

C++——編譯安裝boost庫

 

Trend 12:17:14
安裝 boost到預設目錄
./bootstrap.sh —-with-libraries=all —-with-python=python3 —-prefix=/usr/local
./b2 cxxflags="-std=c++11"
./b2 install —-prefix=/usr/local

 

 

 

編譯安裝boost的第二步。
./b2 cxxflags="-std=c++11"
指定使用c++11的標準,否則無法生成某些需要c++11的庫,如不指定c++11,json庫就無法編譯,會跳過。

cxxflags 不會清楚上一次 cached 的 feature check 結果, 這是需要刪除 cache 結果,
rm -rf bin.v2(其實只要移除裡面的config.log和project-cache.jam檔案即可)

參考: https://blog.csdn.net/cherisegege/article/details/80425545

 

 

gcc g++支援C++11 標準編譯
取別名 :alias g++11="g++ -std=c++11"

g++ 4.8以上都支援c++11標準

 

-I  大寫 i 表示include目錄

-L 表示靜太庫目錄

-l  表示靜態庫的名字

g++ -std=c++11 test.cpp  -o  test  -I/home/soft/boost/build/include -L/home/soft/boost/build/lib -lboost_thread -lpthread -lboost_json  -lboost_timer -lboost_random

 

 

Trend 18:35:59
Ubuntu16.04 cmake找不到boost庫的解決辦法
sudo apt-get install cmake libblkid-dev e2fslibs-dev libboost-all-dev libaudit-dev