編譯 Boost 1.35.0 (Visual Studio 2005 (VC 8.0) + Windows XP)

簡介

  1. Boost 的原始碼可以在官網 http://www.boost.org 找到,或是直接到 sourceforge 下載,網址是:http://tinyurl.com/m7jqo

  2. Boost 有著自己一套的建置系統,叫做 Boost.Build [1],可用在編譯、 安裝、測試等功能上。Boost.Build 則是架構於 Boost.Jam, Boost.Jam 又是 Perforce Jam[2] 的衍生,更詳細的介紹可以在 [3]

    看到。
  3. 通常在 Windows 上安裝 Boost ,最快速、簡易的方法是去 Boost Consulting 下載 installer [4],不過到今天為止, Boost 1.35.0 的 installer 都還沒 release。所以大家來學學自己編譯吧 : )

  4. Boost Getting Started on Windows [5] 是一篇官方的教學文件,有簡易的 bjam 使用方法,但無註明完整安裝的步驟,另外它也簡介了Boost Project 的 layout, simple usage 等等。

  5. Boost 身為最先進、標準的 C++ library ,它大量使用了 generic programming, metaprogramming 等技巧,使得實際上需要編譯成函式庫(.lib, .dll)的部份反而少了,根據 Boost Getting Started on Windows [5] 的說明,只有以下幾個 library 使用時,一定需要先編譯成函式庫(.lib, .dll):

    1. Boost.Filesystem

    2. Boost.IOStreams

    3. Boost.ProgramOptions

    4. Boost.Python

    5. Boost.Regex

    6. Boost.Serialization

    7. Boost.Signals

    8. Boost.Thread

    9. Boost.Wave

    還有幾個則是 optional:

    1. Boost.DateTime

    2. Boost.Graph

    3. Boost.Test

安裝步驟

  1. 下載 source code 並解壓縮。

  2. 使用 Open Visual Studio 2005 Command Prompt 進入 cmd。利用 Open Visual Studio 2005 Command Prompt 的原因有兩點:

    1. 方便呼叫 namke, cl 等 vc toolchain。

    2. 若是電腦上安裝多個編譯器,使用 Open Visual Studio 2005 Command Prompt 通常可透過環境變數,讓 bjam 使用正確的 toolchain。

  3. 取得 bjam.exe。

    1. 可以選擇到 Boost 提供的預先編譯好的 binary,可在http://tinyurl.com/2q36f 下載。

    2. 或是自行編譯,以下是編譯步驟:

      1. $> cd your_dir/boost_1_35_0/tools/jam/src

      2. $> build.bat

      3. 執行完後,boost_1_35_0/tools/jam/src/bin.ntx86 下就放著編譯完後的 bjam.exe 了!

  4. 將上一個步驟的 bjam.exe 放入 PATH 環境變數或是使用絕對路徑呼叫 bjam,並搭配以下的 options 就可開始編譯並安裝 boost:

    • $> bjam.exe --build-dir="your_dir/boost_1_35_0" --build-type=complete --toolset=msvc install

    • --build-dir: boost 解壓縮的檔案,記得 = 前後不可有空白!

    • --build-type: complete 會產生 release, debug ,以及各種設定的對應:如 multithread, debug, 等等。

    • install: 編譯完後,將 header, lib 安裝到指定目錄,預設目錄是:C:/Boost,大小約 2 G。

  5. 更多的客製化安裝,可以使用 bjam --help 查看 options。

    • bjam 是個有趣的東西,當我在 your_idr/boost_1_35_0/tools/jam/src/bin.ntx86 下執行 bjam --help 時,它跑出的訊息並不多,而切換到 your_idr/boost_1_35_0 時卻又是另一回事,它跑出豐富的 Boost 的編譯資訊,後來發現它會去讀取 Jamroot 這個檔案,這是格外要注意的一點。

Reference

  1. Boost.Build: http://www.boost.org/doc/libs/1_35_0/tools/build/v2/index.html

  2. Perforce Jam: http://www.perforce.com/jam/jam.html

  3. Install Boost: http://www.boost.org/doc/libs/1_35_0/doc/html/bbv2/installation.html

  4. Free Download on Boost Consulting: http://www.boost-consulting.com/products/free

  5. Boost Getting Started on Windows: http://www.boost.org/doc/libs/1_35_0/more/getting_started/windows.html

  6. Boost 提供的 bjam binary 下載點(包含許多種平台): http://tinyurl.com/2q36f

  7. Boost Source on Sourceforge: http://tinyurl.com/m7jqo

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值