1. 程式人生 > >Boost庫的下載及總結

Boost庫的下載及總結

boost 庫是c++標準庫的拓展,很實用。

趕緊提升C++技能。

因為有個遊戲安裝需要下載boost庫,查閱晚上相關文件,這麼好的庫應該極大地發揚光大才是啊。

官網http://www.boost.org/

下載地址

https://sourceforge.net/projects/boost/files/boost/1.63.0/

訪問有點慢的話訪問百度網盤下載。

https://pan.baidu.com/s/1bpKPKsf

安裝,可以看到非常簡單,還提供學習網站。

指導手冊

file:///home/wang/Downloads/boost_1_63_0/more/getting_started/unix-variants.html#build-a-simple-program-using-boost

也可以指定安裝目錄,具體查詢--help解決。

./bootstrap.sh --prefix=/usr

./b2 install

[email protected]:~/Downloads/boost_1_63_0$ ./bootstrap.sh
Building Boost.Build engine with toolset gcc... tools/build/src/engine/bin.linuxx86_64/b2
Detecting Python version... 2.7
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/build/doc/html/index.html

執行./b2

The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

    /home/wang/Downloads/boost_1_63_0

The following directory should be added to linker library paths:

    /home/wang/Downloads/boost_1_63_0/stage/lib

執行

./bjam


可以看到已經安裝完成。

寫一個程式進行測試說明

#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>

int main()
{
    using namespace boost::lambda;
    typedef std::istream_iterator<int> in;

    std::for_each(
        in(std::cin), in(), std::cout << (_1 * 3) << " " );
}

[email protected]:~$ g++ -I /home/wang/Downloads/boost_1_63_0 labmda.cpp -o lambda
[email protected]:~$ echo 1 2 3 | ./example
bash: ./example: No such file or directory
[email protected]:~$ echo 1 2 3 | ./lambda
3 6 9 [email protected]:~$

結果,正確安裝。