boost安裝及使用的記錄

來源:互聯網
上載者:User

原文連結:boost安裝及使用的記錄 

其他參考:windows下boost怎樣安裝與使用說明?

http://www.cnblogs.com/finallyliuyu/archive/2010/08/23/1806811.html

http://www.boostpro.com/download/

安裝

ubuntu: 

1) 在新立得(Synaptic)裡搜尋boost安裝即可。

2) 編譯時間候需要如果使用boost的lib檔案,則需要用-l指明。

 

windows: 

1) 事先下載 icu,假設解壓的路徑是 c:\icu。

2) 在 boost首頁下載安裝包,解壓,假設解壓的路徑是 c:\boost\。

3) 編譯或下載bjam。

4) 安裝方式有兩種,一種是install,一種是stage。stage避免把檔案拷貝一遍,推薦該方法。

A  gcc

bjam stage --toolset=gcc -sICU_PATH="c:\icu" --stagedir="c:\boost\bin\gcc" release --without-graph_parallel  --without-***

bjam stage --toolset=gcc -sICU_PATH="c:\icu" --stagedir="c:\boost\bin\gcc" debug --without-graph_parallel  --without-***

(--without-*** 就是不要編譯的庫,比如--without-python --without-wave --without-mpi ,除此之外都編譯)

或者

bjam stage --toolset=gcc -sICU_PATH="c:\icu" --stagedir="c:\boost\bin\gcc" release --without-graph_parallel --with-***

bjam stage --toolset=gcc -sICU_PATH="c:\icu" --stagedir="c:\boost\bin\gcc" debug --without-graph_parallel --with-***

(--with-***就是僅編譯的庫,例如 --with-regex  --with-filesystem)

B msvc (開啟Visual Studio 命令)

bjam stage --toolset=msvc -sICU_PATH="c:\icu" --stagedir="c:\boost\bin\vc10" release --without-***

bjam stage --toolset=msvc -sICU_PATH="c:\icu" --stagedir="c:\boost\bin\vc10" debug --without-***

或者

bjam stage --toolset=msvc -sICU_PATH="c:\icu" --stagedir="c:\boost\bin\vc10" release --with-***

bjam stage --toolset=msvc -sICU_PATH="c:\icu" --stagedir="c:\boost\bin\vc10" debug --with-***

5) 在IDE中添加boost的庫資訊

vs 2010 IDE (每個項目都需要單獨添加,很麻煩)

1.Include Path c:\boost  (root dir)
2.Library Path c:\boost\bin\vc10\lib  (lib dir)
3.Source Path c:\boost\boost  (include-file dir)

CodeBlocks
1.Linker
  Setting -> Compiler and debuger -> Global compiler setting -> Linker setting ->
      Add  (c:\boost \bin\gcc\*.a) (all the lib files)
2.Search
  Setting -> Compiler and debuger -> Global compiler setting -> Search directories -> Compiler ->
      Add (c:\boost)  (root dir)

6) 如果是命令列編譯,可以改如下的bat檔案

A gcc

set boost_root=c:\boost
set boost_lib=%boost_root%\bin\gcc\lib
set use_boost=-I %boost_root% -L %boost_lib%
set filesystem=-lboost_filesystem-mgw44-mt-d-1_46_1 -lboost_system-mgw44-mt-d-1_46_1
set regex=-lboost_regex-mgw44-mt-d-1_46_1

:: example
:: g++ lex.cpp -o lex %use_boost%
:: g++ regex_1.cpp -o regex_1 %use_boost% %regex%
:: g++ traverse_dir.cpp -o traverse_dir_gcc_new %use_boost% %filesystem%

B  msvc

set boost_root=c:\boost
set boost_lib=%boost_root%\bin\vc10\lib
set use_boost=/EHsc /I %boost_root% /MD /link /libpath:%boost_lib%

:: example
:: cl regex_1.cpp /Feregex_1_vc.exe %use_boost%
:: del regex_1.obj

當然,也可以寫一個makefile。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.