編譯Boost 詳細步驟 適用 VC6 VS2003 VS2005 VS2008 VS2010
轉自:http://blog.csdn.net/ajian005/article/details/9720947
vs2008編譯boost
【一、Boost庫的介紹】
Boost庫是一個經過千錘百煉、可移植、提供原始碼的C++庫,作為標準庫的後備,是C++標準化程式的發動機之一。Boost庫由C++標準委員會庫工作組成員發起,其中有些內容有望成為下一代C++標準庫內容。在C++社群中影響甚大,其成員已近2000人。 Boost庫為我們帶來了最新、最酷、最實用的技術,是不折不扣的“準”標準庫。
Boost庫中比較有名的幾個庫:
(1)Regex,正規表示式庫;
(2)Spirit,LL parser framework,用C++程式碼直接表達EBNF;
(3)Graph,圖元件和演算法;
(4)Lambda,在呼叫的地方定義短小匿名的函式物件,很實用的functional功能;
(5)concept check,檢查泛型程式設計中的concept;
(6)Mpl,用模板實現的超程式設計框架;
(7)Thread,可移植的C++多執行緒庫;
(8)Python,把C++類和函式對映到Python之中;
(9)Pool,記憶體池管理;
(10)smart_ptr,智慧指標。
【二、Boost庫的編譯】
【Setp1 準備工作】:
(1)Boost 下載可以到官方網站下載:
build Boost VS2010 IDE
第一步:E:\boost_1_54_0\bootstrap.bat
第二步:b2 --build-dir="E:\build_boost_1_54_0" toolset=msvc-10.0 --build-type=complete stage
(2)安裝VS2008 IDE
【Setp2 編譯Boost】
1.開啟Visual Studio 2008 命令提示視窗
2.進入D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/boost_1_44_0/tools/jam/src
3.執行 build.bat 會在D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/boost_1_44_0
/tools/jam/src/bin.ntx86 生成 bjam.exe檔案.
4.Copy bjam.exe 檔案到 D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/boost_1_44_0 下
6.進入D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/boost_1_44_0 目錄
7.執行bjam.exe 編譯命令,如下:
(1)編譯所有boost動態庫 (release|debug),包括標頭檔案和庫檔案
bjam --toolset=msvc-9.0 --prefix=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output --without-python --build-type=complete link=shared threading=multi install
(2)只編譯 release 版本 regex 動態庫,包括標頭檔案和庫檔案
bjam --toolset=msvc-9.0 --prefix=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output1 --with-regex link=shared threading=multi variant=release runtime-link=shared install
(3)只編譯 release 版本 regex 動態庫,包括庫檔案
bjam --toolset=msvc-9.0
--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output2
--with-regex link=shared threading=multi variant=release runtime-link=shared stage
【注意】: Boost 原始碼所在路徑最好全英文,不要有空格、特殊字元、中文等
編譯要花上30分鐘左右(根據PC效能所定), 會在指定生成目錄:
D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output下生成對應庫檔案和標頭檔案。
8.設定開發環境
開啟VS2008 建立工程, 配置工程屬性
設定包含檔案目錄F:/Develop/BoostlibAndDll/include/boost-1_37/boost
設定引用檔案目錄:F:/Develop/BoostlibAndDll/lib
完成後,可以使用。
【三、介紹Bjam使用】
Usage:
Bjam [options] [properties] [install|stage]
install Install headers and compiled library files to the
======= configured locations (below).
在“--prefix=”指定的目錄下生成所有標頭檔案
(boost原始碼下boost資料夾下所有檔案)和指定庫檔案
--prefix=<PREFIX> Install architecture independent files here.
Default; C:/Boost on Win32
Default; /usr/local on Unix. Linux, etc.
--exec-prefix=<EPREFIX> Install architecture dependent files here.
Default; <PREFIX>
--libdir=<DIR> Install library files here.
Default; <EPREFIX>/lib
--includedir=<HDRDIR> Install header files here.
Default; <PREFIX>/include
stage Build and install only compiled library files
====== to the stage directory.
在“--stagedir=”指定的目錄下生成指定庫檔案
--stagedir=<STAGEDIR> Install library files here
Default; ./stage
【Other Options】:
--build-type=<type> Build the specified pre-defined set of variations
of the libraries. Note, that which variants get
built depends on what each library supports.
minimal (default) - Builds the single
"release" version of the libraries. This
release corresponds to specifying:
"release <threading>multi <link>shared
<link>static <runtime-link>shared" as the
Build variant to build.
complete - Attempts to build all possible
variations.
--build-dir=DIR Build in this location instead of building
within the distribution tree. Recommended!
--show-libraries Displays the list of Boost libraries that require
build and installation steps, then exit.
--layout=<layout> Determines whether to choose library names
and header locations such that multiple
versions of Boost or multiple compilers can
be used on the same system.
versioned (default) - Names of boost
binaries include the Boost version
number and the name and version of the
compiler. Boost headers are installed
in a subdirectory of <HDRDIR> whose
name contains the Boost version number.
system - Binaries names do not include
the Boost version number or the name
and version number of the compiler.
Boost headers are installed directly
into <HDRDIR>. This option is
intended for system integrators who
are building distribution packages.
--buildid=ID Adds the specified ID to the name of built
libraries. The default is to not add anything.
--help This message.
--with-<library> Build and install the specified <library>
If this option is used, only libraries
specified using this option will be built.
--without-<library> Do not build, stage, or install the specified
<library>. By default, all libraries are built.
【Properties】:
toolset=toolset Indicates the toolset to build with.
msvc-6.0 : VC6.0
msvc-7.0: VS2003
msvc-8.0: VS2005
msvc-9.0: VS2008
msvc-10.0: VS2010
variant=debug|release Select the build variant
link=static|shared Whether to build static or shared libraries
threading=single|multi Whether to build single or multithreaded binaries
runtime-link=static|shared Whether to link to static or shared C and C++ runtime.
決定是靜態還是動態連結C/C++標準庫
Bjam 選項、引數說明 |
|
--build-dir=<builddir> |
編譯的臨時檔案會放在builddir裡(編譯完就可以把它刪除了) |
--stagedir=<stagedir> |
存放編譯後庫檔案的路徑,預設是stage |
--build-type=complete |
編譯所有版本,不然只會編譯一小部分版本(相當於: |
variant=debug|release |
決定編譯什麼版本(Debug or Release) |
link=static|shared |
決定使用靜態庫還是動態庫 |
threading=single|multi |
決定使用單執行緒還是多執行緒庫 |
runtime-link=static|shared |
決定是靜態還是動態連結C/C++標準庫 |
--with-<library> |
只編譯指定的庫,如輸入--with-regex就只編譯regex庫了 |
--show-libraries |
顯示需要編譯的庫名稱 |
【四、Bjam 生成檔案的分析】
(1)生成 Release 版本,多執行緒,動態連結C++標準庫 的regex 動態庫
bjam --toolset=msvc-9.0
--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output2
--with-regex link=shared threading=multi variant=release runtime-link=shared stage
-- 輸出: boost_regex-vc90-mt.lib
boost_regex-vc90-mt-1_44.lib
boost_regex-vc90-mt-1_44.dll
(2)生成 Release 版本,多執行緒,靜態連結C++標準庫 的regex 動態庫
bjam --toolset=msvc-9.0
--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output2
--with-regex link=shared threading=multi variant=release runtime-link= static stage
-- 輸出: 沒有這種配置
(3)生成 Release 版本,多執行緒,動態連結C++標準庫 的regex靜態庫
bjam --toolset=msvc-9.0
--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output2
--with-regex link= static threading=multi variant=release runtime-link=shared stage
-- 輸出: libboost_regex-vc90-mt-s.lib
libboost_regex-vc90-mt-1_44.lib
(4)生成 Release 版本,多執行緒,靜態連結C++標準庫 的regex 靜態庫
bjam --toolset=msvc-9.0
--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output3
--with-regex link=static threading=multi variant=release runtime-link=static stage
-- 輸出:libboost_regex-vc90-mt-s.lib
libboost_regex-vc90-mt-s-1_44.lib
--------------------------------------------------------------------------------------------------------------------
(1)生成 Debug 版本,多執行緒,動態連結C++標準庫 的regex 靜態庫
bjam --toolset=msvc-9.0
--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output4
--with-regex link=static threading=multi variant=debug runtime-link=shared stage
-- 輸出: libboost_regex-vc90-mt-gd.lib
libboost_regex-vc90-mt-gd-1_44.lib
(2)生成 Debug 版本,多執行緒,靜態連結C++標準庫 的regex 靜態庫
bjam --toolset=msvc-9.0
--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output5
--with-regex link=static threading=multi variant=debug runtime-link=static stage
-- 輸出: libboost_regex-vc90-mt-sgd.lib
libboost_regex-vc90-mt-sgd-1_44.lib
(3)生成 Debug 版本,多執行緒,動態連結C++標準庫 的regex 動態庫
bjam --toolset=msvc-9.0
--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output5
--with-regex link=shared threading=multi variant=debug runtime-link=shared stage
- 輸出: boost_regex-vc90-mt-gd.lib
boost_regex-vc90-mt-gd-1_44.lib
boost_regex-vc90-mt-gd-1_44.dll
(4)生成 Debug 版本,多執行緒,靜態連結C++標準庫 的regex動態庫
bjam --toolset=msvc-9.0
--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output5
--with-regex link=shared threading=multi variant=debug runtime-link=static stage
-- 輸出:沒有這種配置
【總結】:
(1) 編譯成功後,Bjam 都會給你生成一對一樣的匯入庫檔案或者靜態庫檔案(如下),
唯一不同的是兩個檔名稱一個在後面加上了boost版本資訊, 為了讓使用者知道使用的boost的版本資訊。
boost_regex-vc90-xxxxx.lib
boost_regex-vc90-xxxxx-1_44.lib
(2) Bjam編譯選項 有4個, 理論上應該有 2*2*2*2 = 16 種配置
ink= static| shared
threading= single |multi
variant=release|debug
runtime-link= static |shared
實際使用的多為多執行緒, 所以 threading= multi, 這樣剩下的3個選項組成的編譯配置就是上面所羅列的, 其中靜態連結C++標準庫的boost動態庫這種配置也不存在, 所以就只有4種情況。
(3)
link= static : 靜態庫。 生成的庫檔名稱以 “lib”開頭
link= shared : 動態庫。生成的庫檔名稱無“lib”開頭
threading= mult : 支援多執行緒。 生成的庫檔名稱中包含 “-mt”
variant=release 生成的庫檔名稱不包含 “-gd”
variant= debug 生成的庫檔名稱包含 “-gd”
runtime-link= static 生成的庫檔名稱包含 “-s”
runtime-link= shared 生成的庫檔名稱不包含 “-s”
相關文章
- doris編譯和安裝部署詳細步驟編譯
- MySQL 5.6.19編譯安裝詳細步驟MySql編譯
- 交叉編譯PHP5、Nginx、Squid的詳細步驟編譯PHPNginxUI
- CentOS7.2編譯安裝PHP7.2.3之史上最詳細步驟。CentOS編譯PHP
- Windows C++ log4cplus編譯開發配置詳細步驟WindowsC++編譯
- 抖音去水印詳細原理步驟及介面編寫
- 關於vs2003、vs2005、vs2008和vs2010專案互轉的總結
- 配置PLSQL Developer詳細步驟SQLDeveloper
- Oracle Stream配置詳細步驟Oracle
- IOS之GCD詳細步驟iOSGC
- osg原始碼編譯步驟原始碼編譯
- LVM建立的詳細步驟LVM
- docker安裝portainer詳細步驟DockerAI
- MySQL的安裝步驟(詳細)MySql
- mysql建立master/slave詳細步驟MySqlAST
- Github配置ssh key詳細步驟Github
- LAMP 編譯安裝基本步驟LAMP編譯
- 學習編譯原理的步驟編譯原理
- SpringBoot獲得Maven-pom中版本號和編譯時間戳詳細步驟Spring BootMaven編譯時間戳
- CentOS 7 安裝MongoDB詳細步驟CentOSMongoDB
- 安裝fbprophet模組詳細步驟
- 曲折的gcc升級詳細步驟GC
- Linux安裝JDK詳細步驟LinuxJDK
- NFS伺服器搭建詳細步驟NFS伺服器
- 戴爾電腦重灌系統詳細步驟(適用於xp、win7、win10等)Win7Win10
- CentOS 7上安裝WordPress詳細步驟CentOS
- Linux安裝jdk的詳細步驟。LinuxJDK
- CentOS 7.4安裝redis 4.0詳細步驟CentOSRedis
- CentOS 6.5下Redis安裝詳細步驟CentOSRedis
- mysql 主從複製搭建詳細步驟MySql
- MySQL 升級詳細步驟 (包括 Percona)MySql
- ORACLE資料庫升級詳細步驟Oracle資料庫
- Linux安裝jdk的詳細步驟LinuxJDK
- java筆記2-java編譯步驟Java筆記編譯
- Linux系統下編譯Openssl 步驟:Linux編譯
- 特別詳細的react專案搭建步驟React
- UBUNTU手動安裝JDK的詳細步驟UbuntuJDK
- Git學習2 --- Git安裝詳細步驟Git