令人费解的Boost.Python的1.54(调试版本)的依赖关系Python27.lib在Windows [英] Puzzling dependency of Boost.Python 1.54 (debug build) to Python27.lib on Windows
问题描述
我必须做一些明显的错误,但战斗了几个小时之后,我无法取得进一步进展:
I must be doing some kind of obvious mistake but after hours of fighting I'm unable to make further progress:
升级到升压1.54,之后CMake的2.8.12和Python 2.7.5(所有三个来自的略的早期次要版本),我的项目在Debug配置不再联系(他们的释放链路罚款)。我与2012年VS建立的一切都被更新之前正常工作
After upgrading to Boost 1.54, CMake 2.8.12 and Python 2.7.5 (all three from slightly earlier minor versions), the Python bindings of my project no longer link in Debug configuration (they link fine in Release). I'm building with VS 2012. Everything was working properly before the update.
我建提升的标准方式: bootstrap.bat
然后按 B2地址模型= 64 =工具MSVC-11.0
。我的系统有一个Python 2.7的安装是由B2回升:
I built Boost the standard way: bootstrap.bat
followed by b2 address-model=64 toolset=msvc-11.0
. My system has a Python 2.7 installation which is picked up by b2:
notice: [python-cfg] Configuring python...
notice: [python-cfg] Registry indicates Python 2.7 installed at "C:\Python27\"
notice: [python-cfg] Checking interpreter command "python"...
notice: [python-cfg] running command 'DIR /-C /A:S "C:\Python27\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: "C:\Python27\Include"
notice: [python-cfg] library path: "C:\Python27\libs"
notice: [python-cfg] DLL search path: "C:\Python27"
我没有在我的机器上的任何其他Python安装。
I don't have any other Python installation on my machine.
当我在我的项目运行CMake的,一切看起来也不错:
When I run CMake on my project, everything looks good too:
Found PythonLibs: optimized;C:/Python27/libs/python27.lib;debug;C:/Python27/libs/python27_d.lib (found version "2.7.5")
如预期在调试链接器的命令行的相关部分:
The relevant part of the linker's command line in Debug is as expected:
"C:\franz\dev\boost_1_54_0\stage\lib\libboost_python-vc110-mt-gd-1_54.lib" "C:\Python27\libs\python27_d.lib"
当我终于建立了项目调试:
LINK : fatal error LNK1104: cannot open file 'python27.lib'
由于无处是 python27.lib
链接程序的命令行中提到的,我编辑 libboost_python-vc110-MT-GD-1_54.lib
用十六进制编辑才发现它包含引用 python27.lib
(形式为 / DEFAULTLIB的:python27。 LIB
),在那里我没有料想到会 python27_d.lib
引用代替(其中有没有)。
Since nowhere is python27.lib
mentioned on the linker's command line, I edited libboost_python-vc110-mt-gd-1_54.lib
with an hexadecimal editor only to find out that it contains references to python27.lib
(of the form /DEFAULTLIB:"python27.lib"
) where I would have expected references to python27_d.lib
instead (of which there is none).
是建设加速,当我做错了什么?这是升压1.54的已知问题Boost.Python的?任何帮助将大大AP preciated。
Am I doing something wrong when building Boost? Is this a known problem with Boost.Python in Boost 1.54? Any help would be greatly appreciated.
更新#1:我再次升压1.51和1.50和同样的问题发生试过,所以它不是在升压回归
Update #1: I tried again with Boost 1.51 and 1.50 and the same problem occurs, so it's not a regression in Boost.
更新#2:我删除从我的Python安装Python的LIB(python27_d.lib)的调试版本,从而恢复到香草Python安装。然后我重建升压1.51和我的项目(与CMake的报告如预期单个库文件:找到PythonLibs:C:/Python27/libs/python27.lib(发现版2.7.5)
)。问题仍然存在,但是错误消息现在提到python27_d.lib: LINK:致命错误LNK1104:无法打开文件'python27_d.lib
Update #2: I removed the debug version of the Python lib (python27_d.lib) from my Python installation, thus reverting to a vanilla Python installation. I then rebuilt Boost 1.51 and my project (with CMake reporting a single library file as expected: Found PythonLibs: C:/Python27/libs/python27.lib (found version "2.7.5")
). The problem persists, however the error message now mentions python27_d.lib: LINK : fatal error LNK1104: cannot open file 'python27_d.lib'
!
更新3:使用进程监视器一>我可以说python27_d.lib没有在 C:\\ Python27 \\库\\
它实际驻留:
Update #3: Using Process Monitor I could that python27_d.lib is not searched in C:\Python27\libs\
where it actually resides:
3:35:28.0550683 PM link.exe 10132 CreateFile C:\franz\dev\appleseed\build\appleseed.python\python27_d.lib NAME NOT FOUND Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
3:35:28.0551846 PM link.exe 10132 CreateFile C:\franz\dev\boost_1_50_0\stage\lib\python27_d.lib NAME NOT FOUND Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
3:35:28.0552474 PM link.exe 10132 CreateFile C:\franz\dev\boost_1_50_0\stage\lib\Debug\python27_d.lib PATH NOT FOUND Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
3:35:28.0553595 PM link.exe 10132 CreateFile C:\franz\dev\appleseed\build\appleseed.python\python27_d.lib NAME NOT FOUND Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
3:35:28.0556105 PM link.exe 10132 CreateFile C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64\python27_d.lib NAME NOT FOUND Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
3:35:28.0559637 PM link.exe 10132 CreateFile C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\lib\amd64\python27_d.lib NAME NOT FOUND Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
3:35:28.0560984 PM link.exe 10132 CreateFile C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64\python27_d.lib NAME NOT FOUND Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
3:35:28.0561741 PM link.exe 10132 CreateFile C:\franz\dev\appleseed\build\appleseed.python\python27_d.lib NAME NOT FOUND Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, AllocationSize: n/a
更新#4 :相关的问题:的Visual C ++调试库命名约定
推荐答案
我解决了这一问题,这要归功于提示在这篇文章中发现:的 VISUAL C ++调试库命名约定。
I fixed the problem, thanks to hints found in this post: Visual C++ debug library naming convention.
基本上,头文件 pyconfig.h
附带的Python(在 C:\\ Python27 \\包括\\
)部队在调试版本链接到 python27_d.lib
(通过的#pragma评论()
指令),无论这个库的存在与否。
Basically, the header file pyconfig.h
that ships with Python (in C:\Python27\include\
) forces linking to python27_d.lib
in Debug build (via a #pragma comment()
directive), regardless of whether this library exists or not.
诀窍是永远不会包括 Python.h
直接,而是包括Boost的该文件的包装,升压/蟒蛇/细节/ wrap_python .HPP
这需要禁止违规护理的#pragma评论()
指令。
The trick is to never include Python.h
directly, but instead to include Boost's wrapper for that file, boost/python/detail/wrap_python.hpp
which takes care of disabling the offending #pragma comment()
directive.
这篇关于令人费解的Boost.Python的1.54(调试版本)的依赖关系Python27.lib在Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!