<menu id="w8yyk"><menu id="w8yyk"></menu></menu>
  • <dd id="w8yyk"><nav id="w8yyk"></nav></dd>
    <menu id="w8yyk"></menu>
    <menu id="w8yyk"><code id="w8yyk"></code></menu>
    <menu id="w8yyk"></menu>
    <xmp id="w8yyk">
    <xmp id="w8yyk"><nav id="w8yyk"></nav>
  • 網站首頁 > 物聯資訊 > 技術分享

    編譯Boost 詳細步驟

    2016-09-28 00:00:00 廣州睿豐德信息科技有限公司 閱讀
    睿豐德科技 專注RFID識別技術和條碼識別技術與管理軟件的集成項目。質量追溯系統、MES系統、金蝶與條碼系統對接、用友與條碼系統對接

    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 下載可以到官方網站下載:

    http://www.boost.org/

     

    (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=release,threading=multi;
    link=shared|static;runtime-link=shared)
     
    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”

    RFID管理系統集成商 RFID中間件 條碼系統中間層 物聯網軟件集成
    最近免费观看高清韩国日本大全