centos6.4 編譯安裝boost.python 1.54--來自官方文檔


1.gcc版本>3.2

2.Yum 的 boost 和boost-python文件很小,好像不行。所以編譯安裝。

3.boost庫分為三種:無需編譯;單獨編譯;部分編譯。python需要單獨編譯。

4.使用無需編譯庫的一個例子:

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) << " " );
}

Copy the text of this program into a file called example.cppNow, in the directory where you saved example.cpp, issue the following command:

c++ -I path/to/boost_1_54_0 example.cpp -o example

To test the result, type:

echo 1 2 3 | ./example

5.編譯中有warning沒有關系,但不能有error.

6.安裝單獨編譯子庫。注意,工作目錄。工作目錄決定了b2 install的安裝內容。

    1. $ cd path/to/boost_1_54_0
      $ ./bootstrap.sh --help  查看配置選項
    2. 使用合適的配置選項運行./boostrap.sh
    3. 運行./b2 install安裝
    4. 以上方法可以安裝全部,選擇合適參數可以只安裝部分庫(--show-libraries and --with-libraries=library-name-list),這種方法跟7安裝部分庫有什么不同?

7.安裝定制庫

    1. 如果使用非系統默認的編譯器,需要使用boos.built編譯。
    2. 如果想要使用非標准的編譯方法,也需要使用boost.build.
    3. boost.build是用於開發測試安裝軟件的一個文本系統。安裝方法boost.build的方法:  
        1. Go to the directory tools/build/v2/.
        2. Run bootstrap.sh
        3. Run b2 install --prefix=PREFIX where PREFIX is the directory where you want Boost.Build to be installed
        4. Add PREFIX/bin to your PATH environment variable.
        5. 試運行一個例子,會產生可執行代碼。Copy PREFIX/share/boost-build/examples/hello to a different directory, then change to that directory and run:

          PREFIX/bin/b2
    4. 安裝完畢boost.build后,回到boost根目錄。運行
      b2 --build-dir=build-directorytoolset=toolset-name  stage  比如:
      $ cd ~/boost_1_54_0
      $ b2 --build-dir=/tmp/build-boost toolset=gcc stage :會產生一個靜態共享非調試多線程的boost庫。如果想要產生所有類型的boost庫,使用built-type=complete。 statge目標會將庫二進制文件放在stage/lib中,可以使用stage-dir=...指定。查看幫助 b2 --help.為了限制時間可以:
      • reviewing the list of library names with --show-libraries
      • limiting which libraries get built with the --with-library-name or --without-library-name options
      • choosing a specific build variant by adding release or debug to the command line.
    5. 如果沒有安裝python,那么boost.python會不報錯的跳過,但是會產生一個警告。
    6. 如果有zip bzzip2c錯誤,那么是因為沒有安裝先關的庫,bzip2需要安裝bz2庫;zip是z庫。這些錯誤無關緊要,但是其他error需要關注
    7. 如果仿佛看起來找不到編譯器連接器,考慮建議里一個user-config.jam文件,如果不是這個問題,咨詢郵件列表。

8.一個用Link例子。

9.編譯好的庫的命名規則。xxx.a xxx.so.

10.如果你的程序Link到了一個庫,那么運行的時候,需要設定好環境變量,以便能夠在運行時找到動態庫。LD_LIBRARY_PATH。

$ VARIABLE_NAME=path/to/lib/directory:${VARIABLE_NAME}
$ export VARIABLE_NAME

 

 
        

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM