2014-11-24 86 views
0

我的英语很差,所以我很感激你是否试图理解我的问题。

Boost.Python在Visual Studio 2008中的链接器错误



我已经Python3.3,升压1.50.0和Visual Studio 2008的安装,并且他们都做工精细。

现在我想通过使用Boost Python库在C++中嵌入python 2.7.6,所以我下载了Portable Python 2.7.6.1(来自portablepython.com/)。

我下载了Boost库。再次将它们提取到另一个路径中,按照构建教程进行编译。

一切似乎都没错,但是当我试图编译我的代码时,出现链接器错误。

Error LNK1104 cannot open file 'python32.lib' 

我不知道为什么它不是“python27.lib”

我很困惑,因为我从来没有安装Python3.2,我已经修改了用户config.jam中,以确保所有路径已被重定向到我的Portable Python(2.7)文件夹,并且新的Boost库成功构建而没有错误。

我一直在努力解决这个问题了几个星期,大量应用的方式,但它仍然无法正常工作


我所做的事情是:

  1. 下载升压C++库(boost_1_50_0.7z从www.boost.org/users/history/version_1_50_0.html)

  2. 其解压缩到我的升压根路径(d:\ PROJ \ ThirdPartyLib \ boost_1_50_0

  3. 下载便携式的Python 2.7.6.1(从portablepython.com/wiki/PortablePython2.7.6。1 /)

  4. 其解压缩到d:\ Py27Test

  5. 修改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" : ;

  6. 执行Visual Studio命令提示符(x86)

    1. cd /D D:\Proj\ThirdPartyLib\boost_1_50_0
    2. bootstrap
    3. bjam --toolset=msvc-9.0 --python=2.7 --user-config=D:\Proj\ThirdPartyLib\boost_1_50_0\user-config.jam --debug-configuration

      调试infomations是:

      notice: [python-cfg] Configuring python...

      notice: [python-cfg] user-specified version: "2.7"

      notice: [python-cfg] Checking interpreter command "python"...

      ​​3210

      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"

  7. 埃克可爱的Visual Studio 2008

    1. 添加d:\ PROJ \ ThirdPartyLib \ boost_1_50_0编译器包含路径
    2. 添加d:\ PROJ \ ThirdPartyLib \ boost_1_50_0 \台\ lib中到链接库路径
  8. 创建一个测试代码:

#define BOOST_PYTHON_STATIC_LIB 
#include <boost/python.hpp> 
#include <iostream> 

int main(int argc, char** argv) { 
    return 0; 
} 
  • Complie代码和我会得到一个链接器错误(错误LNK1104不能打开文件 'python32.lib'

  • 没有符合我想念什么?

    还是有没有人有任何想法来解决这个问题?

    预先感谢

    +0

    感谢您的通知。是的,但我不知道在哪里可以找到.lib文件。我试图将Python27.lib重命名为Python32.lib,但它不起作用(在运行时崩溃)。 我搜索了名称“Python32.lib”,但我找不到有关32位库的有用信息。 – 2014-11-24 14:53:25

    回答

    0

    最后,我解决了这个问题。

    1. 添加d:\ Py27Test \软件\包括编译器包含路径
    2. 添加d:\ Py27Test \软件\库到链接库路径

    好像如果我不包括Python的.h,它会链接到一个默认的库文件。 因此,我添加这些路径后,它现在可以工作。