【发布时间】:2014-11-24 13:54:44
【问题描述】:
我的英语很差,所以如果您尝试理解我的问题,我将不胜感激。
我已经安装了 Python3.3、Boost 1.50.0 和 Visual Studio 2008,它们都运行良好。
现在我想使用 Boost Python 库在 C++ 中嵌入 python 2.7.6,所以我下载了 Portable Python 2.7.6.1(来自portablepython.com/)。
我下载了 Boost lib。再次1.50.0,解压到另一个路径,按照构建教程编译。
一切似乎都很好,但是当我尝试编译我的代码时,我得到了一个链接器错误。
Error LNK1104 cannot open file 'python32.lib'
我不知道为什么它不是'python27.lib'
我很困惑,因为我从未安装过 Python3.2,并且我已经修改了 user-config.jam 以确保所有路径都已重定向到我的 Portable Python(2.7) 文件夹,并且新的 Boost 库已成功构建且没有错误。
几个星期以来我一直在尝试解决这个问题,使用了很多方法,但它仍然不起作用
我所做的所有事情都是:
下载 Boost C++ 库(来自 www.boost.org/users/history/version_1_50_0.html 的 boost_1_50_0.7z)
将它们解压到我的 boost 根路径(D:\Proj\ThirdPartyLib\boost_1_50_0)
下载Portable Python 2.7.6.1(来自portablepython.com/wiki/PortablePython2.7.6.1/)
将它们提取到 D:\Py27Test
修改
user-config.jam,添加如下文本并保存到D:\Proj\ThirdPartyLib\boost_1_50_0\using python : 2.7 : "D:\Py27Test\App" : "D:\Py27Test\App\include" : "D:\Py27Test\App\libs" : ;-
执行 Visual Studio 命令提示符 (x86)
cd /D D:\Proj\ThirdPartyLib\boost_1_50_0bootstrap-
bjam --toolset=msvc-9.0 --python=2.7 --user-config=D:\Proj\ThirdPartyLib\boost_1_50_0\user-config.jam --debug-configuration
调试信息是:notice: [python-cfg] Configuring python...notice: [python-cfg] user-specified version: "2.7"notice: [python-cfg] Checking interpreter command "python"...notice: [python-cfg] running command 'DIR /-C /A:S "D:\Py27Test\App\python.exe" 2>&1'notice: [python-cfg] running command '"python" -c "from sys import *; print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))" 2>&1'notice: [python-cfg] ...requested configuration matched!notice: [python-cfg] Details of this Python configuration:notice: [python-cfg] interpreter command: "python"notice: [python-cfg] include path: "D:\Py27Test\App\include"notice: [python-cfg] library path: "D:\Py27Test\App\libs"
>notice: [python-cfg] DLL search path: "D:\Py27Test\App"
-
执行 Visual Studio 2008
- 将D:\Proj\ThirdPartyLib\boost_1_50_0添加到编译器包含路径
- 将 D:\Proj\ThirdPartyLib\boost_1_50_0\stage\lib 添加到链接器库路径
创建测试代码:
#define BOOST_PYTHON_STATIC_LIB #include <boost/python.hpp> #include <iostream> int main(int argc, char** argv) { return 0; }
- 编译代码,我会得到一个链接器错误(Error LNK1104 cannot open file 'python32.lib')
我错过了什么吗?
或者有没有人有任何想法来解决这个问题?
提前致谢
【问题讨论】:
-
感谢您的通知。是的,我做到了,但我不知道在哪里可以找到 .lib 文件。我试图将 Python27.lib 重命名为 Python32.lib,但它不起作用(在运行时崩溃)。我搜索了名称“Python32.lib”,但找不到有关 32 位库的有用信息。
标签: python c++ visual-studio boost