Boost Python 的安装配置以及示例 (支持python3.x)
来源:互联网 发布:ubuntu 没有rc.local 编辑:程序博客网 时间:2024/06/02 19:07
Boost Python 的安装配置以及示例 (支持python3.x)
目录
- Boost Python 的安装配置以及示例 支持python3x
- 目录
- 简介
- Boost Python 安装 Ubuntu
- Hello World 示例
- python35
- python27
- 其他示例
简介
BoostPython 可以让 Python 和 C++ 最大程度的结合起来。
在与其他语言交互时,BoostPython 并不是像 execjs 在执行新的js代码时fork一个新的进程去执行,所有的内容都发生在同一个进程中,只是当前程序的控制权在Python解释器手中还是在你预先编译好的lib中。
关于 BoostPython 的详细介绍
Boost Python 安装 (Ubuntu)
测试环境: Ubuntu 16.04
我默认使用g++ 作为编译器,要使用cmake或者其他配置请参考 说明
- 编译安装
下载 最新版 boost
# 下载完成后tar -xzvf boost_1_65_1.tar.gzcd boost_1_65_1# sudo find / -name "python3.5m" # 寻找你系统下的 python3.5m# which python3 # 寻找你系统下 python3 的安装路径echo "using mpi ;using gcc : : g++ ;using python : 3.5 : /usr/bin/python3 : /usr/include/python3.5m : /usr/local/lib ;" > ~/user-config.jam./bootstrap.sh --with-python=/usr/bin/python3 --with-python-version=3.5 --with-python-root=/usr/local/lib/python3.5 --prefix=/usr/localsudo ./b2 install -a --with=allsudo ldconfig
- apt 安装
目前apt安装为1.58版本,若要安装更新的版本请进行编译安装
sudo apt-get install libboost-all-dev# 搜索 libpython3.5m.sosudo find / -name "libpython3.5m.so"# cd 到上面搜索到的目录cd /usr/lib/x86_64-linux-gnu/sudo ln -s libboost_python-py35.so libboost_python3.so
提示:
-如果在编译安装时更改了 prefix path, 需要更改下面的 makefile 里的 BOOST_INC and BOOST_LIB
-我系统默认的python版本为 python3.5, 若要更改为python2.7, 请更改 makefile 里的 “PYTHON_VERSION”
安装完成
Hello World 示例
python3.5
git clone https://github.com/zpoint/Boost-Python-Examples.gitcd Boost-Python-Examples/Examples/hello_extmakepython3Python 3.5.2 (default, Nov 17 2016, 17:05:23)[GCC 5.4.0 20160609] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import hello_ext>>> hello_ext.greet()'hello, world'
python2.7
git clone https://github.com/zpoint/Boost-Python-Examples.gitcd Boost-Python-Examples/Examples/hello_extvim makefile # 把第一行的 "PYTHON_VERSION = 3.5" 更改成 "PYTHON_VERSION = 2.7"makepythonPython 2.7.12 (default, Nov 19 2016, 06:48:10)[GCC 5.4.0 20160609] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import hello_ext>>> hello_ext.greet()'hello, world'
其他示例
Boost Python 官方示例
个人对官方示例的实现 github
由于官方示例较为简介,所以个人又把官方示例上提到的点都实现了一遍
阅读全文
1 0
- Boost Python 的安装配置以及示例 (支持python3.x)
- MongoDB windows 安装以及如何配置python的支持
- 安装支持 python3 的 xadmin
- python学习浅谈(python2.x以及python3.x的区别、IDE)
- python学习笔记(1)之如何在python3.x下安装PIL、numpy以及matplotlib
- boost的安装配置
- 关于Python(x,y)的安装以及spyder的安装
- windows下安装Scrapy步骤(支持Python3.X)
- Vim支持+python和+python3,以及来回切换。
- 安装过 python3.X 后,python 2.7.x 打不开 idle
- boost.python和python-dev的ubuntu 8.10下的安装,版本以及注意事项(7)
- Red5的安装配置以及AS3连接red5简单示例
- suds 在python3.x上的安装
- Python 2.x与Python3.x中inpu的区别
- 【Python】让Python2.x与Python3.x共存的方法
- 在CentOS 6.X 上面安装 Python 2.7.X以及安装locust遇到ssl的问题
- Python同时安装py2.x和py3.x,以及Windows下virtualenv和flask的安装
- boost的编译安装 以及boost regex的使用
- [BZOJ]1414: [ZJOI2009]对称的正方形 二分+hash
- Linux常用Shell脚本珍藏
- 用Oracle sqlldr导入文本文件TXT 总结
- 常用类--Date,Random
- HDU 1429 胜利大逃亡(续) (bfs+状态压缩)
- Boost Python 的安装配置以及示例 (支持python3.x)
- 安全性——XSS、XSRF
- Resource for Machine Learning
- Camera基本属性了解及设置
- 依赖注入和控制反转有什么区别吗?
- 文字随文本框大小自适应变化
- linux安装python3.6
- idea个人常用快捷键0.1
- leetcode Day5 21MergTwoSortedLists