centos6.4 编译安装boost.python 1.54--来自官方文档

1.gcc版本>3.2html

2.Yum 的 boost 和boost-python文件很小,好像不行。因此编译安装。python

3.boost库分为三种:无需编译;单独编译;部分编译。python须要单独编译。ios

4.使用无需编译库的一个例子:c++

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:bootstrap

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的安装内容。ui

    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.安装定制库this

    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:spa

          PREFIX/bin/b2PREFIX
    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
相关文章
相关标签/搜索