发布时间:2019-09-15 10:14:59编辑:auto阅读(2417)
最近项目使用c++操作python脚本,选用boost.python库。在window下编译安装很顺利,但是在linux下一直编译不通过,总是提示找不到头文件。linux版本为rhel5.7。后来询问同事,原来是同事将原来系统自带的python2.4删除掉了,然后手动编译安装了python3.3。
换到另外一台机器,重新下载boost,使用以下命令,顺利编译成功
./bootstrap.sh --with-python=/usr/bin/python
./bjam --build-type=minimal --with-python variant=release link=static threading=multi address-model=64 --debug-configurations install
说明:生成bjam工具的时候要增加with-python参数同时指定python可执行程序的路径,具体参数可以运行./bootstrap --help查看
这样编译出来的库是链接python2.4生成的库,至于为什么自己安装的3.3编译不成功,原因还有待查找,
为什么会报 No best alternative for /python_for_extensions错误。
--------------------------------------------------------------------------------------------
2014/5/5 19:15补充:
针对自定义的版本,要使用以下命令编译
./b2 --with-python include="/usr/local/python3.3.5/include/python3.3m/"
这里要使用b2进行编译,据说b2是第二个版本的bjam,以后不要使用bjam了
另外自行编译python的时候最好要编译动态库
./configure --prefix=/usr/local/python3.3.5 --enable-shared
make && make install
上一篇: Python读写properties文件
下一篇: Python 获取时间戳
48676
47693
38477
35691
30133
26862
25883
20739
20494
18890
210°
284°
317°
335°
328°
321°
374°
438°
567°
555°