3

正しい Python 構成で b2 を使用して、boost 1.50.0 ライブラリをコンパイルしました。コマンドからの関連する出力は次のb2 --debug-configurationとおりです。

notice: [python-cfg] Configuring python...
notice: [python-cfg]   user-specified cmd-or-prefix: "C:\Python33z\python"
notice: [python-cfg] Checking interpreter command "C:\Python33z\python"...
notice: [python-cfg] running command 'DIR /-C /A:S "C:\Python33z\python.exe" 2>&
1'
notice: [python-cfg] running command '"C:\Python33z\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] Configuring python...
notice: [python-cfg]   user-specified cmd-or-prefix: "C:\Python33z\python"
notice: [python-cfg] Checking interpreter command "C:\Python33z\python"...
notice: [python-cfg] running command 'DIR /-C /A:S "C:\Python33z\python.exe" 2>&
1'
notice: [python-cfg] running command '"C:\Python33z\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: "C:\Python33z\python"
notice: [python-cfg]   include path: "C:\Python33z\Include"
notice: [python-cfg]   library path: "C:\Python33z\libs"
notice: [python-cfg]   DLL search path: "C:\Python33z"
notice: [msvc-cfg] msvc-10.0 detected, command: 'C:\Program Files (x86)\Microsof
t Visual Studio 10.0\VC\bin\cl.exe'
notice: will use 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cl.
exe' for msvc, condition <toolset>msvc-10.0

...updating 4 targets...
msvc.archive bin.v2\libs\python\build\msvc-10.0\debug\link-static\threading-mult
i\libboost_python3-vc100-mt-gd-1_50.lib
common.copy stage\lib\libboost_python3-vc100-mt-gd-1_50.lib
bin.v2\libs\python\build\msvc-10.0\debug\link-static\threading-multi\libboost_py
thon3-vc100-mt-gd-1_50.lib
        1 file(s) copied.
msvc.archive bin.v2\libs\python\build\msvc-10.0\release\link-static\threading-mu
lti\libboost_python3-vc100-mt-1_50.lib
common.copy stage\lib\libboost_python3-vc100-mt-1_50.lib
bin.v2\libs\python\build\msvc-10.0\release\link-static\threading-multi\libboost_
python3-vc100-mt-1_50.lib
        1 file(s) copied.
...updated 4 targets...


The Boost C++ Libraries were successfully built!

リンカー ディレクトリを正しく設定し、適切な出力ファイルにリンクしました (libboost_ python3-vc100-mt-1_50.libリリース時およびlibboost_python3-vc100-mt-gd-1_50.libデバッグ時)。私は自己コンパイルされた python ディストリビューションを使用していますが、標準のものでも試してみましたが、結果に違いはありません。

コンパイル時に発生するリンク エラーは次のとおりです。

error LNK2019: unresolved external symbol "__declspec(dllimport) protected: __thiscall boost::python::detail::str_base::str_base(char const *)" (__imp_??0str_base@detail@python@boost@@IAE@PBD@Z) referenced in function "public: __thiscall boost::python::str::str(char const *)" (??0str@python@boost@@QAE@PBD@Z)
error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall boost::python::detail::str_base::~str_base(void)" (__imp_??1str_base@detail@python@boost@@QAE@XZ) referenced in function "public: __thiscall boost::python::str::~str(void)" (??1str@python@boost@@QAE@XZ)
error LNK2019: unresolved external symbol "__declspec(dllimport) class boost::python::api::object __cdecl boost::python::import(class boost::python::str)" (__imp_?import@python@boost@@YA?AVobject@api@12@Vstr@12@@Z) referenced in function _main
fatal error LNK1120: 3 unresolved externals

これらのエラーを生成したテスト コードは次のようになります。

using namespace boost::python;
object main_module = import("__main__");

同じビルド構成で使用Boost.Filesystemしましたが、問題は発生しませんでした。

誰かがこの問題で私を助けてくれることを願っています。本当に混乱しています!

更新: define に関するあいまいなテキストを読んだだけBOOST_PYTHON_STATIC_LIBです。これで正しい方向に向かっているかどうかはわかりませんが(ビルドプロセスで言及されていないため)、どちらにしても、さらに混乱するエラーが表示されます:

LINK : fatal error LNK1104: cannot open file 'python27.lib'

python-cfg の出力で、python33 dist (アプリケーションが既にリンクしている python33.lib) が見つかったことを明確に示しているのに、なぜその lib とリンクしようとするのかわかりません。

4

1 に答える 1

5

BOOST_PYTHON_STATIC_LIB最初の問題:未解決の外部リンク エラーを修正するには、定義が実際に正しい方法であることが判明しました。静的ライブラリとリンクするときに必要な定義のようです。これは明らかなようですが、ここでは言及されていません: http://www.boost.org/doc/libs/1_50_0/libs/python/doc/building.html

2 番目の問題: その定義を追加した後、次のリンク エラーが発生しました。これは、正しい Python 構成で再ビルドする前に実行しなかったためb2 cleanです (つまり、クリーンアップするまで何も再コンパイルされませんでした!)。コンパイラ関連の出力ですが、それは私をだましました。

于 2012-08-05T17:56:22.423 に答える