日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

Build boost 1.66.0 with c++11

發布時間:2025/6/15 c/c++ 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Build boost 1.66.0 with c++11 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

build boost

以1.66.0為例, build boost很簡單了:
build b2

./bootstrap.sh --prefix=/opt/boost
會生成 b2 bjam project-config.jam.
--prefix 作用在 project-config.jam 里, 會在 build 時設置 include 和 lib 的安裝目錄
option.set prefix : /opt/boost ;
option.set exec-prefix : /opt/boost ;
option.set libdir : /opt/boost/lib ;
option.set includedir : /opt/boost/include ;
build boost
include 和 build 好的 libs 會安裝到之前指定的 folder 中

./b2 install
提升 build 速度, 可以制定 build thread number (jobs)

./b2 -j8 install
gcc5.4 默認是不開啟 c++11 的, 某些依賴 c++11 特性的代碼不會生效. 部分 lib 依賴 c++11 的功能, 如果不支持此特性, 就不會被編譯. 比如 fiber 在沒有開啟 c++11 支持下就不會被編譯.
所以需要打開 c++11 的支持, gcc5.4 下, 只打開 --std=c++11 是不能編譯fiber的, 使用 --std=c++14 或者 --std=c++17 可以成功

./b2 cxxflags="--std=c++17" -j8 install
b2 常用的 property 還有
variant=debug|release Select the build variant
link=static|shared Whether to build static or shared libraries
在根目錄下, 默認 build release 下 static 和 shared

build one boost library

如果需要單獨 build 某 library, 可以在 /libs/***/build/ 下 run b2 進行編譯
以 fiber 為例

cd libs/fiber/build
../../../b2 cxxflags="-std=c++11"?? (gcc4.8)
build 產生的中間文件在 bin.v2
cj@ubuntu:/opt/boost_1_64_0/bin.v2/libs/fiber$ tree . └── build └── gcc-5.4.0 └── release └── threading-multi ├── algo │ ├── algorithm.o ... ├── libboost_fiber.so.1.64.0 ... └── timed_mutex.o

clean cached cxx11_** result

在 b2 build 開始后, 首先輸出的是 configuration checks:
Performing configuration checks - 32-bit : no (cached) - 64-bit : yes (cached) ... - symlinks supported : yes (cached) - C++11 mutex : yes (cached) - Boost.Config Feature Check: cxx11_auto_declarations : yes (cached) - Boost.Config Feature Check: cxx11_constexpr : yes (cached) ...
改變 cxxflags 不會清楚上一次 cached 的 feature check 結果, 這是需要刪除 cache 結果,

rm -rf bin.v2(其實只要移除里面的config.log和project-cache.jam文件即可)

總結

以上是生活随笔為你收集整理的Build boost 1.66.0 with c++11的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。