日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

Build boost 1.66.0 with c++11

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

build boost

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

./bootstrap.sh --prefix=/opt/boost
會生成 b2 bjam project-config.jam.
--prefix 作用在 project-config.jam 里, 會在 build 時設(shè)置 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 默認(rèn)是不開啟 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
在根目錄下, 默認(rèn) build release 下 static 和 shared

build one boost library

如果需要單獨(dú) build 某 library, 可以在 /libs/***/build/ 下 run b2 進(jìn)行編譯
以 fiber 為例

cd libs/fiber/build
../../../b2 cxxflags="-std=c++11"?? (gcc4.8)
build 產(chǎn)生的中間文件在 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 結(jié)果, 這是需要刪除 cache 結(jié)果,

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

總結(jié)

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

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。