Linux 編譯安裝Boost__Linux

來源:互聯網
上載者:User
linux平台下要編譯安裝除gcc和gcc-c++之外,還需要兩個開發庫:bzip2-devel 和python-devel,因此在安裝前應該先保證這兩個庫已經安裝:

#yum install gcc gcc-c++ bzip2 bzip2-devel bzip2-libs python-devel -y 然後是去官網下載源碼包, 地址
下載,解壓,按照如下步驟:


#tar xvzf boost_1_50_0.tar.gz 進入boost_1_50_0目錄:


#cd boost_1_50_0

然後是編譯安裝,boost源碼包中有配置指令碼,直接用就可以:


#sh ./bootstrap.sh

Building Boost.Build engine with toolset gcc... tools/build/v2/engine/bin.linuxx86_64/b2 Detecting Python version... 2.6 Detecting Python root... /usr Unicode/ICU support for Boost.Regex?... not found. Generating Boost.Build configuration in project-config.jam... Bootstrapping is done. To build, run: ./b2 To adjust configuration, edit 'project-config.jam'. Further information: - Command line help: ./b2 --help - Getting started guide: http://www.boost.org/more/getting_started/unix-variants.html - Boost.Build documentation: http://www.boost.org/boost-build2/doc/html/index.html 接下來就是編譯,重點關注是否編譯成功:


#./b2 然後就是漫長的等待,如果最後出現:


The Boost C++ Libraries were successfully built! The following directory should be added to compiler include paths: /home/gang/BAK/boost_1_50_0 The following directory should be added to linker library paths: /home/gang/BAK/boost_1_50_0/stage/lib

最後,sudo ./b2 install --prefix=/usr/local

1、  boost中大部分庫是不用編譯成動態或者靜態連結庫。

2、  只有regex,thread等幾個庫比較麻煩一點.要編譯。

3、  如果用gcc編譯器-l指定動態連結程式庫的路徑,還要指定標頭檔的路徑。

4、  或者連結的boost庫放到.c或.cpp之後,否則連結不能通過,編譯可以通過。

如下所示:g++ -lz -lpthread hh.c -lboost_filesystem -lboost_thread

http://blog.163.com/yungang_z/blog/static/175153133201262445539767/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.