问题描述
我必须做一些明显的错误,但在战斗后的几个小时我无法取得进一步的进展:
升级到Boost 1.54之后,CMake 2.8。 12和Python 2.7.5(所有这三个都来自稍早的较小版本),我的在Debug配置中不再链接(它们在Release中链接正常)。
我建立了Boost的标准方式: bootstrap.bat
后跟 b2 address-model = 64 toolset = msvc-11.0
。我的系统有一个Python 2.7安装,由b2拾起:
注意:[python-cfg]配置python ...
注意:[python-cfg]注册表指示Python 2.7安装在C:\ Python27 \
注意:[python-cfg]检查解释器命令python...
注意:[python-cfg]运行命令'DIR / -C / A:S'C:\Python27\python.exe2& 1'
注意: python -cfrom sys import *; print('version =%d。%d\\\
platform =%s\\\
prefix =%s\\\
exec_prefix =%s\\\
executable =%s'%(version_info [0] ,version_info [1],platform,prefix,exec_prefix,executable))2& 1'
notice:[python-cfg]
notice:[python-cfg]这个Python配置的细节:
notice:[python-cfg] interpreter命令:python
notice:[python-cfg] include path:C :\Python27 \Include
注意:[python-cfg]库路径:C:\Python27\libs
注意:[python-cfg] DLL搜索路径:C: \ Python27
我的机器上没有安装任何其他Python。
当我在我的项目上运行CMake时,一切看起来也不错:
:optimized; C:/Python27/libs/python27.lib; debug; C:/Python27/libs/python27_d.lib(发现版本2.7.5)
Debug中链接器命令行的相关部分如预期:
C:\franz\dev\boost_1_54_0\stage\lib\libboost_python-vc110-mt-gd-1_54.libC:\Python27\libs\python27_d.lib
当我最终在Debug中构建项目时:
$ b
LINK:致命错误LNK1104:无法打开文件'python27.lib'
由于链接器命令行上没有提到 python27.lib
,我编辑了 libboost_python-vc110-mt -gd-1_54.lib
使用十六进制编辑器只是为了发现它包含对 python27.lib
的引用c> / DEFAULTLIB:python27.lib)其中我会期望引用 python27_d.lib
(其中没有)。
我在构建Boost时做错了什么?这是Boost 1.54中Boost.Python的一个已知问题吗?任何帮助将非常感谢。
更新#1:我再次尝试使用Boost 1.51和1.50,同样的问题也发生了,因此它不是Boost中的回归。
更新#2:我从我的Python安装中删除了Python lib(python27_d.lib)的调试版本,从而恢复为一个原生的Python安装。然后我重建Boost 1.51和我的项目(与CMake报告单个库文件,如预期:找到PythonLibs:C:/Python27/libs/python27.lib(发现版本2.7.5)
)。问题仍然存在,但是错误消息现在提到python27_d.lib: LINK:致命错误LNK1104:无法打开文件'python27_d.lib'
!
更新3::使用我可以在 C:\Python27\libs\
中搜索它实际上驻留的位置:
$ b
3:35:28.0550683 PM link.exe 10132 CreateFile C:\franz\dev\appleseed\build\appleseed.python\ python27_d.lib名称NOT FOUND期望访问:读属性,处置:打开,选项:打开Reparse点,属性:n / a,ShareMode:读取,写入,删除,分配大小:n / a
3:35:28.0551846 PM link.exe 10132 CreateFile C:\franz\dev\boost_1_50_0\stage\lib\python27_d.lib名称未找到希望的访问权限:读取属性,处置:打开,选项:打开Reparse点,属性: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期望的访问:读属性,处置:打开,选项:打开Reparse点,属性:n / a,ShareMode:读取,写入,删除,分配大小:n / a
3: 35:28.0553595 PM link.exe 10132 CreateFile C:\franz\dev\appleseed\build\appleseed.python\python27_d.lib名称未找到所需的访问权限:读取属性,处置:打开,选项:打开Reparse点属性:n / a,ShareMode:读取,写入,删除,分配大小: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名称未找到希望的访问权限:读取属性,处置:打开,选项:打开分解点,属性:n / a,ShareMode:读取,写入,删除,分配大小: n / a
3:35:28.0559637 PM link.exe 10132 CreateFile C:\Program文件(x86)\Microsoft Visual Studio 11.0 \VC\\\\\\\\\\\\\\python27_d.lib NAME NOT FOUND期望的访问:读取属性,处置:打开,选项:打开Reparse点,属性:n / a,ShareMode:读取,写入,删除,分配大小:n / a
3:35:28.0560984 PM链接。 exe 10132 CreateFile C:\Program Files(x86)\Windows Kits\8.0\Lib\win8\um\x64\python27_d.lib名称未找到所需的访问权限:读取属性,处置:打开,选项:打开Reparse点,属性:n / a,ShareMode:读,写,删除,分配大小:n / a
3:35:28.0561741 PM link.exe 10132 CreateFile C:\franz\dev\appleseed \build\appleseed.python\python27_d.lib名称未找到所需的访问权限:通用读取,处理:打开,选项:同步IO非警报,非目录文件,属性:n / a,ShareMode:Read,AllocationSize :n / a
更新#4 :相关问题:
我修复了这个问题,感谢这篇文章中的提示: Visual C ++调试库命名约定。
基本上,头文件 pyconfig.h
( C:\ Python27 \include\
)强制链接到 python27_d.lib
Python.h
,而是包括Boost的包装文件, boost / python / detail / wrap_python。 hpp
,它负责禁用违规的 #pragma comment()
指令。 I must be doing some kind of obvious mistake but after hours of fighting I'm unable to make further progress:
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.
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"
I don't have any other Python installation on my machine.
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"
When I finally build the project in Debug:
LINK : fatal error LNK1104: cannot open file 'python27.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).
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.
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.
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'
!
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
Update #4: related question: Visual C++ debug library naming convention
I fixed the problem, thanks to hints found in this post: Visual C++ debug library naming convention.
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.
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.
这篇关于在Windows上,Boost.Python 1.54(调试版)对Python27.lib的依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!