Boost.python 编译和使用
2013-11-07 16:29
585 查看
cent os
1) 安装python
yum install python26
2) 安装python devel
3) 库、include
-lboost -lboost_python -lpython2.6
-I/usr/include/python2.6/
4) 安装boost
-lboost -I/usr/local/boost
安装boost_python。 默认boost不是完全安装?
1)编译bjam
sh ./bootstrap.sh
2)编译boost python
进入boost源码目录,执行
sudo ./bjam -toolset=gcc --with-python --with-python --layout=tagged --build-type=complete stage
顺利完成后,将在stage目录下生成相应的lib
======================================使用===========================================
1) c/c++编译成so
2) so中增加代码行
python是boost::python名字空间。
def的第一个参数是导出给python调用的; 第二个参数是c/c++函数
其中, MODULE名字和so的名字必须相同(不用带.so); BOOST_PYTHON_MODULE只能有一个, 否则就会报错重定义。
1) 安装python
yum install python26
2) 安装python devel
yum search python | grep -i devel
yum install python-devel.x86_64 =====================否则一堆怪异的找不到头文件错误
3) 库、include
-lboost -lboost_python -lpython2.6
-I/usr/include/python2.6/
4) 安装boost
-lboost -I/usr/local/boost
安装boost_python。 默认boost不是完全安装?
1)编译bjam
sh ./bootstrap.sh
2)编译boost python
进入boost源码目录,执行
sudo ./bjam -toolset=gcc --with-python --with-python --layout=tagged --build-type=complete stage
顺利完成后,将在stage目录下生成相应的lib
======================================使用===========================================
1) c/c++编译成so
2) so中增加代码行
python是boost::python名字空间。
def的第一个参数是导出给python调用的; 第二个参数是c/c++函数
其中, MODULE名字和so的名字必须相同(不用带.so); BOOST_PYTHON_MODULE只能有一个, 否则就会报错重定义。
BOOST_PYTHON_MODULE(libcheck) { python::def("CheckInit", CheckInit); python::def("CheckCaseClassIdContinous", CheckCaseClassIdContinous); python::def("GetOKMessages", GetOKOKMessages); python::def("GetERMessages", GetERERMessages); }
相关文章推荐
- Boost.Python:安装使用(兼具Boost.Python库中Python编译版本的修改)
- suse 11下编译使用boost-python报错:error: changes meaning of 'keywords' from 'struct boost::python::detail::keywords'
- 编译boost python模块遇到的错误:../../libraries/boost_1_44_0/boost/python/detail/wrap_python.hpp:75:24: fatal error: patchlevel.h: No such file or directory
- 使用boost::python的链接出错
- VS2008 编译 boost::python boost::serialization 方法
- 使用boost.python静态库
- c++中使用boost::regex(由于标准库中版本过低,导致不支持多行,需手动编译添加最新版的boost库)
- Boost下载安装编译配置使用指南
- boost 1.56.0 编译及使用
- 使用bjam编译boost
- 使用MinGW 编译python扩展模块
- Python 出现需要使用fPIC重新编译的问题
- XGBoost:在Python中使用XGBoost
- Boost下载安装编译配置使用指南
- 在MinGW中编译Boost.Python
- 使用MinGW编译Boost
- Windows下使用VS2008编译OpenCV 2.1 添加Intel TBB和Python支持
- 使用源码编译wxpython-基于python2.7
- Boost下载安装编译配置使用指南
- windows平台使用Microsoft Visual C++ Compiler for Python 2.7编译python扩展