首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> C語言 >> C++ >> 關於C++

C++Builder 2007 安裝 Boost 1.36.0 完整指南

     編輯:關於C++

在 C++Builder 2007 (CodeGear RAD Studio) 中編譯安裝 Boost 1.36.0

Boost 庫編譯過程複雜,本文提供針對 Borland 編譯器的完整步驟,含 Debug/Release/完整三種建置模式。

準備工作

  • 下載 boost_1_36_0.7z (源碼, ~25MB, 解壓後 ~175MB)
  • 下載 boost-jam-3.1.16-1-ntx86.zip (含 bjam.exe)
  • 解壓源碼至 X:\tmp\boost_1_36_0 (需 2GB+ 可用空間)
  • 將 bjam.exe 複製至源碼根目錄
  • 建立安裝目標目錄 E:\boost_1_36_0

編譯步驟

  1. 開啟命令提示字元,切換至源碼目錄
  2. 查看需建置模組:
    bjam --show-libraries
  3. 建置 Debug 版 (排除龐大/不需模組):
    bjam install --toolset=borland --prefix="E:\boost_1_36_0" debug
        --without-wave --without-mpi --without-python --without-math --without-graph

    關鍵參數:--toolset=borland 指定編譯器,debug 產生帶 -d- 的除錯庫。

  4. 建置 Release 版:
    bjam install --toolset=borland --prefix="E:\boost_1_36_0" release
        --without-wave --without-mpi --without-python --without-math --without-graph
  5. (可選) 完整建置 (含靜態/動態/單執行緒/多執行緒/除錯/發布所有組合):
    bjam install --toolset=borland --prefix="E:\boost_1_36_0" --build-type=complete

    耗時 ~1小時,產生 -s- (靜態執行階段) 庫檔。

安裝結果結構

E:\boost_1_36_0\
├── include\boost-1_36\     # 頭文件
└── lib\                    # 庫文件
    ├── *.dll               # 動態連結庫
    ├── *1_36.lib           # 導入庫
    ├── *.lib               # 靜態庫
    ├── *-d-*               # Debug 版
    ├── *-mt-*              # 多執行緒版
    └── *-sg-*              # 單執行緒版 (完整建置才有)

C++Builder 2007 專案設定

  1. Project → Default Options → C++Builder:
    • Include Path 加入 E:\boost_1_36_0\include\boost-1_36
    • Library Path 加入 E:\boost_1_36_0\lib
  2. Tools → Options → C++ Options → Paths and Directories 同步設定

驗證測試程式

#include <vcl.h>
#pragma hdrstop
#include <boost/regex.hpp>

void __fastcall TForm1::Button1Click(TObject *Sender) {
    boost::regex reg("(.*)");
    bool b = boost::regex_match("I love C++Builder.", reg);
    if (b) ShowMessage("Boost 安裝成功!");
}

分別在 Debug/Release 組態下編譯執行驗證。

常見問題

  • 磁碟空間不足 → 確保 2GB+ 可用空間
  • 缺少 -d- 庫 → 未建置 Debug 版
  • 缺少 -s- 庫 → 未完整建置 (--build-type=complete)
  • bjam 參數格式:-- 雙減號、= 前後無空格、路徑用雙引號
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved