4

私は何らかの明らかな間違いを犯しているに違いありませんが、何時間も戦った後、私はそれ以上進歩することができません:

Boost 1.54、CMake 2.8.12、および Python 2.7.5 (3 つすべてが少し前のマイナー バージョンから) にアップグレードした後、私のプロジェクトの Python バインディングはデバッグ構成でリンクしなくなりました (リリースでは正常にリンクされます)。VS 2012 でビルドしています。更新前はすべて正常に動作していました

Boost を標準的な方法で作成bootstrap.batしましたb2 address-model=64 toolset=msvc-11.0。私のシステムには、b2 によって取得される Python 2.7 がインストールされています。

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 がインストールされていません。

プロジェクトで CMake を実行すると、すべてがうまく見えます。

Found PythonLibs: optimized;C:/Python27/libs/python27.lib;debug;C:/Python27/libs/python27_d.lib (found version "2.7.5")

デバッグでのリンカーのコマンド ラインの関連部分は、次のとおりです。

"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リンカのコマンドラインにはどこにも言及されていないので、16 進エディタで編集したところ、(形式の) へのlibboost_python-vc110-mt-gd-1_54.lib参照が含まれていることがわかりました。python27.lib/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 が期待どおりに単一のライブラリ ファイルを報告しました: Found PythonLibs: C:/Python27/libs/python27.lib (found version "2.7.5"))。問題は解決しませんが、エラー メッセージに python27_d.lib: LINK : fatal error LNK1104: cannot open file 'python27_d.lib'!

更新 #3: Process Monitorを使用すると、python27_d.lib がC:\Python27\libs\実際に存在する場所で検索されない可能性があります。

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++ デバッグ ライブラリの命名規則

4

2 に答える 2

9

この投稿にあるヒントのおかげで、問題を修正しました: Visual C++ デバッグ ライブラリの命名規則

基本的に、pyconfig.hPython (in) に同梱されているヘッダー ファイルは、このライブラリが存在するかどうかに関係なく、(ディレクティブを介して) デバッグ ビルドへのC:\Python27\include\リンクを強制します。python27_d.lib#pragma comment()

Python.h秘訣は、直接インクルードするのではなく、そのファイルの Boost のラッパーをインクルードすることです。これにより、問題のあるディレクティブboost/python/detail/wrap_python.hppが無効になります。#pragma comment()

于 2013-11-01T16:40:40.990 に答える
1

boost/python/detail/wrap_python.hpp代わりにインクルードPython.hすると、プログラムのデバッグ バージョンをビルドする場合でも、Python のリリース バージョンを使用できます。

Python のデバッグ バージョンを自分でコンパイルした場合は、Python のデバッグ バージョンにリンクする Boost のデバッグ バージョンをビルドできます。(私は VS2013 を使用していますが、プロセスは VS2010 と VS2012 で同じはずです)。

最初に、my_config.bjamconatiningなどと呼ばれるテキスト ファイルを作成します。

using python : 2.7                                     #version 
: C:\\Python-2.7.10-64bit-dbg-msvc12\\python_d.exe     #executable
: C:\\Python-2.7.10-64bit-dbg-msvc12\\include          #includes
: C:\\Python-2.7.10-64bit-dbg-msvc12\\libs             #libs
: <python-debugging>on ;

Boost のデバッグ バージョンをビルドするには、bootstrap.bat最初に実行b2し、次に次のオプションを指定します。

b2 ^
--build-dir=build__64bit-dbg-msvc12 ^
--build-type=complete ^
--stagedir=stage__64bit-dbg-msvc12 ^
--user-config=my_config.bjam ^
address-model=64 ^
python-debugging=on ^
define=BOOST_PYTHON_DEBUG ^
define=BOOST_PYTHON_NO_LIB ^
link=shared ^
toolset=msvc-12.0 ^
variant=debug ^
stage

これでうまくいくはずです。BOOST_PYTHON_DEBUGプログラムのデバッグ バージョンをコンパイルするときにも定義する必要があります。

于 2015-08-14T09:28:48.520 に答える