Ubuntu 14.04 安装boost-python并配置工程指南
来源:互联网 发布:js兼容性问题怎么解决 编辑:程序博客网 时间:2024/06/05 18:57
先是在MAC OSX上折腾半天无关,又花了点时间折腾Ubuntu,好歹OK了,在这里记录一下过程。
1. 安装python-dev
sudo apt-get install python-dev
2. 手动安装boost
下载boost源代码并解压到某个目录(假设为[boost-src]),然后编译boost(c++11 +python +fPIC)
./bootstrap --with-python=[python-bin-path]./b2 cxxflags=-fPIC cflags=-fPIC --c++11注:不太记得--c++11是否应该添加在./booststrap命令行中或是都不添加,可以都试试flag是否被识别。
3. 手动安装gflags
下载gflags源代码并解压到某个目录(假设为[gflags-src]),然后编辑CMakeList,添加-fPIC选项(在文件靠近开头的地方添加下面一行):
set (CMAKE_POSITION_INDEPENDENT_CODE True)然后生成Makefile
cmake .然后检查是否在CMakeFiles/flags.cmake中成功生成-fPIC
grep -R fPIC CMakeFiles/编译gflags(+fPIC)
makesudo make install
在工程的根目录下创建boost-build.jam,添加下列行
boost-build /home/ubuntu/package/boost_1_60_0/tools/build/src ;其中后面的这个路径应该为你本机里包含bootstrap.jam的路径,通常就在[boost-src]里。
然后在包装c++函数给python的源码文件目录中添加Jamroot文件,示例如下(详见中文注释):
# Copyright David Abrahams 2006. Distributed under the Boost# Software License, Version 1.0. (See accompanying# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)import python ;if ! [ python.configured ]{ ECHO "notice: no Python configured in user-config.jam" ; ECHO "notice: will use default configuration" ; using python ;}# Specify the path to the Boost project. If you move this project,# adjust this path to refer to the Boost root directory.# 注:此目录应该指向工程自己的boost-build.jam所在目录use-project boost : ../../.. ;# Set up the project-wide requirements that everything uses the# boost_python library from the project whose global ID is# /boost/python.# 注:下面示例动态库so工程,文件路径应该指向你自己的这两个.a文件的安装路径project : requirements <link>shared <library-file>/usr/local/lib/libboost_python.a <library-file>/usr/local/lib/libgflags.a ;# Declare the three extension modules. You can specify multiple# source files after the colon separated by spaces.# 注:此处应包含所有生成so所需要编译的源代码文件python-extension word_net : wordnet_python_wrapper.cc wordnet_tool.cc word_tool.cc utils.cc ;# Put the extension and Boost.Python DLL in the current directory, so# that running script by hand works.install convenient_copy : word_net : <install-dependencies>on <install-type>SHARED_LIB <install-type>PYTHON_EXTENSION <location>. ;# A little "rule" (function) to clean up the syntax of declaring tests# of these extension modules.local rule run-test ( test-name : sources + ){ import testing ; testing.make-test run-pyd : $(sources) : : $(test-name) ;}# Declare test targets# 注:建议添加test脚本配置run-test wordnet : word_net wordnet_python_test.py ;
0 0
- Ubuntu 14.04 安装boost-python并配置工程指南
- Boost 下载安装配置指南
- Ubuntu 14.04安装Sublime Text 2并配置python环境
- Ubuntu 15.04 安装 boost-python
- ubuntu 14.04 安装boost
- Ubuntu 14.04+cuda7+caffe 安装配置指南
- Ubuntu安装Sublime并配置python开发环境
- Ubuntu下安装Komoto Edit 并配置运行python代码
- Ubuntu 10.04 安装配置指南
- Ubuntu 10.04 安装配置指南
- Ubuntu 14.04下安装并配置 TeXLive2014
- 服务器安装并配置Ubuntu Server 14.04
- ubuntu安装并配置jdk
- Ubuntu安装并配置mysql
- Boost 安装指南
- Boost 安装指南
- Boost 安装指南
- Caffe + Ubuntu 14.04 + CUDA 6.5 新手安装配置指南
- 在word中使用vba遍历Range对象的Characters
- 交易订单处理失败,请稍后再试(ali64)
- [绍棠] 使用NSFileHandle类对文件进行基本操作,IOS文件操作
- 前端dom优化
- JAVA中SQL操作
- Ubuntu 14.04 安装boost-python并配置工程指南
- 《Apache Kylin客户端系统功能测试说明》
- 视频格式尺寸定义
- 第四周-求解长方形的周长和面积
- Caffe 初学拾遗(十) Layer Catalogue (Data Layer)
- LeetCode 190 Reverse Bits (位运算 推荐)
- 能让你少写1000行代码的20个正则表达式
- JS 多种方法实现弹框确认
- JSON专题-Ajax中Json应用