您的位置:首页 > 运维架构 > Linux

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

2013-11-10 10:35 751 查看
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.cpp. Now, 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的安装内容。

$ cd path/to/boost_1_54_0
$ ./bootstrap.sh --help  查看配置选项


使用合适的配置选项运行./boostrap.sh

运行./b2 install安装

以上方法可以安装全部,选择合适参数可以只安装部分库(--show-libraries and --with-libraries=library-name-list),这种方法跟7安装部分库有什么不同?

7.安装定制库

如果使用非系统默认的编译器,需要使用boos.built编译。

如果想要使用非标准的编译方法,也需要使用boost.build.

boost.build是用于开发测试安装软件的一个文本系统。安装方法boost.build的方法:  

Go to the directory tools/build/v2/.

Run bootstrap.sh

Run b2 install --prefix=PREFIX where PREFIX is the directory where you want Boost.Build to be installed

Add PREFIX/bin to your PATH environment variable.

试运行一个例子,会产生可执行代码。Copy
PREFIX
/share/boost-build/examples/hello[/code] to a different directory, then change to that directory and run:

PREFIX
/bin/b2[/code]

安装完毕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.

如果没有安装python,那么boost.python会不报错的跳过,但是会产生一个警告。

如果有zip bzzip2c错误,那么是因为没有安装先关的库,bzip2需要安装bz2库;zip是z库。这些错误无关紧要,但是其他error需要关注

如果仿佛看起来找不到编译器连接器,考虑建议里一个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



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: