2013-03-23 90 views
3

我一直在嘗試編譯Boost.Python'quickstart'($ BOOST_PATH \ libs \ python \ examples \ quickstart)的例子,並且遇到了問題。錯誤編譯Boost.Python快速啓動

首先,我的環境:

  • 操作系統:Windows 7旗艦版64位
  • Python版本:2.7 32位
  • C++編譯器:VC10
  • 加速版本:1.53.0

最初,我有問題編譯Boost.Python庫文件,但發生在this堆棧溢出線程解決d我的問題是解釋如何在VS2010中設置包含目錄,並將boost編譯指向我的python目錄。然後我就用命令編譯Boost.Python的快速入門例子:

bjam toolset=msvc --verbose-test test 

第幾次我試圖這樣我打了一個解析的外部符號錯誤,告訴我它找不到升壓蟒蛇libary即使它應該是我在第一個鏈接中設置的庫目錄中。現在,它給了我下面的輸出:

error: No best alternative for /python_for_extensions 
    next alternative: required properties: <python>2.7 <target-os>windows 
     matched 
    next alternative: required properties: <python>2.7 <target-os>windows 
     matched 
error: No best alternative for /python_for_extensions 
    next alternative: required properties: <python>2.7 <target-os>windows 
     matched 
    next alternative: required properties: <python>2.7 <target-os>windows 
     matched 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\property.jam:649: in find-replace from module object(property-map)@1 
error: Ambiguous key <target-type>PYTHON_EXTENSION <abi>ms <asynch-exceptions>off <binary-format>pe <debug-store>object <debug-symbols>on <embed-manifest>on <exception-handling>on <extern-c-nothrow>off <hardcode-dll-paths>true <host-os>windows <include>../../../.. <inlining>off <install-dependencies>off <library>object(file-target)@1112 <library>object(file-target)@1114 <library>object(file-target)@1116 <link>shared <main-target-type>PYTHON_EXTENSION <midl-robust>yes <midl-stubless-proxy>yes <optimization>off <os>NT <pch>on <preserve-test-targets>on <profiling>off <python-debugging>off <python.interpreter>C:\Python27\python <python>2.7 <rtti>on <runtime-debugging>on <runtime-link>shared <stdlib>native <strip>off <suppress-import-lib>true <symlink-location>project-relative <target-os>windows <target>object(file-target)@1132 <threadapi>win32 <threading>multi <toolset-msvc:version>10.0 <toolset>msvc <user-interface>console <variant>debug <warnings-as-errors>off <warnings>on <xdll-path>/C:/Program Files (x86)/boost/boost_1_53_0/bin.v2/libs/python/build/msvc-10.0/debug/threading-multi 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\property.jam:626: in object(property-map)@1.find from module object(property-map)@1 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\type.jam:335: in generated-target-ps-real from module type 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\type.jam:360: in generated-target-ps from module type 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\type.jam:270: in type.generated-target-suffix from module type 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\virtual-target.jam:511: in virtual-target.add-prefix-and-suffix from module virtual-target 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\virtual-target.jam:470: in _adjust-name from module object(file-target)@1132 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\virtual-target.jam:253: in abstract-file-target.__init__ from module object(file-target)@1132 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\virtual-target.jam:564: in object(file-target)@1132.__init__ from module object(file-target)@1132 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/kernel\class.jam:88: in class.new from module class 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\generators.jam:565: in generator.generated-targets from module object(msvc-linking-generator)@1127 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/tools\builtin.jam:869: in linking-generator.generated-targets from module object(msvc-linking-generator)@1127 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/tools\msvc.jam:1061: in generated-targets from module object(msvc-linking-generator)@1127 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\generators.jam:463: in construct-result from module object(msvc-linking-generator)@1127 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\generators.jam:416: in run-really from module object(msvc-linking-generator)@1127 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\generators.jam:390: in generator.run from module object(msvc-linking-generator)@1127 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/tools\builtin.jam:784: in object(msvc-linking-generator)@1127.run from module object(msvc-linking-generator)@1127 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\generators.jam:978: in try-one-generator-really from module generators 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\generators.jam:1040: in try-one-generator from module generators 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\generators.jam:1254: in construct-really from module generators 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\generators.jam:1338: in generators.construct from module generators 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\targets.jam:1495: in construct from module object(typed-target)@71 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\targets.jam:1298: in object(typed-target)@71.generate from module object(typed-target)@71 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\targets.jam:732: in generate-really from module object(main-target)@932 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\targets.jam:704: in object(main-target)@932.generate from module object(main-target)@932 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\targets.jam:848: in targets.generate-from-reference from module targets 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\targets.jam:1217: in generate-dependencies from module object(typed-target)@77 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\targets.jam:1269: in object(typed-target)@77.generate from module object(typed-target)@77 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\targets.jam:732: in generate-really from module object(main-target)@934 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\targets.jam:704: in object(main-target)@934.generate from module object(main-target)@934 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\targets.jam:848: in targets.generate-from-reference from module targets 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\targets.jam:1217: in generate-dependencies from module object(alias-target-class)@81 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\targets.jam:1269: in object(alias-target-class)@81.generate from module object(alias-target-class)@81 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\targets.jam:732: in generate-really from module object(main-target)@936 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2/build\targets.jam:704: in object(main-target)@936.generate from module object(main-target)@936 
C:/Program Files (x86)/boost/boost_1_53_0/tools/build/v2\build-system.jam:736: in load from module build-system 
C:\Program Files (x86)\boost\boost_1_53_0\libs\python\example\quickstart\..\..\..\..\tools\build\v2/kernel\modules.jam:283: in import from module modules 
C:\Program Files (x86)\boost\boost_1_53_0\libs\python\example\quickstart\..\..\..\..\tools\build\v2/kernel/bootstrap.jam:142: in boost-build from module 
C:\Program Files (x86)\boost\boost_1_53_0\libs\python\example\quickstart\boost-build.jam:7: in module scope from module 

編輯1:

原來我上面張貼的錯誤信息時,當你在* -config.jam文件的不止一個定義你的Python目錄。現在我得到原來的錯誤信息:

...patience... 
...patience... 
...found 1745 targets... 
...updating 10 targets... 
compile-c-c++ bin\msvc-10.0\debug\threading-multi\extending.obj 
extending.cpp 
msvc.link.dll bin\msvc-10.0\debug\threading-multi\extending.pyd 
    Creating library bin\msvc-10.0\debug\threading-multi\extending.lib and object bin\msvc-10.0\debug\threading-multi\extending.exp 
msvc.manifest.dll bin\msvc-10.0\debug\threading-multi\extending.pyd 
capture-output bin\test_ext.test\msvc-10.0\debug\threading-multi\test_ext 
     1 file(s) copied. 
====== BEGIN OUTPUT ====== 
Trying: 
    from extending import * 
Expecting nothing 
ok 
Trying: 
    hi = hello('California') 
Expecting nothing 
ok 
Trying: 
    hi.greet() 
Expecting: 
    'Hello from California' 
ok 
Trying: 
    invite(hi) 
Expecting: 
    'Hello from California! Please come soon!' 
ok 
Trying: 
    hi.invite() 
Expecting: 
    'Hello from California! Please come soon!' 
ok 
Trying: 
    class wordy(hello): 
     def greet(self): 
      return hello.greet(self) + ', where the weather is fine' 
Expecting nothing 
ok 
Trying: 
    hi2 = wordy('Florida') 
Expecting nothing 
ok 
Trying: 
    hi2.greet() 
Expecting: 
    'Hello from Florida, where the weather is fine' 
ok 
Trying: 
    invite(hi2) 
Expecting: 
    'Hello from Florida! Please come soon!' 
ok 
1 items had no tests: 
    test_extending.run 
1 items passed all tests: 
    9 tests in test_extending 
9 tests in 2 items. 
9 passed and 0 failed. 
Test passed. 

EXIT STATUS: 0 
====== END OUTPUT ====== 
**passed** bin\test_ext.test\msvc-10.0\debug\threading-multi\test_ext.test 
msvc.link bin\test_embed.test\msvc-10.0\debug\threading-multi\test_embed.exe 
LINK : warning LNK4001: no object files specified; libraries used 
LINK : error LNK2001: unresolved external symbol _mainCRTStartup 
bin\test_embed.test\msvc-10.0\debug\threading-multi\test_embed.exe : fatal error LNK1120: 1 unresolved externals 

     call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86 >nul 
link /NOLOGO /INCREMENTAL:NO /DEBUG /MACHINE:X86 /subsystem:console /out:"bin\test_embed.test\msvc-10.0\debug\threading-multi\test_embed.exe" /LIBPATH:"C:\Python27\libs" @"bin\test_embed.test\msvc-10.0\debug\threading-multi\test_embed.exe.rsp" 
     if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% 

...failed msvc.link bin\test_embed.test\msvc-10.0\debug\threading-multi\test_embed.exe bin\test_embed.test\msvc-10.0\debug\threading-multi\test_embed.pdb... 
...removing bin\test_embed.test\msvc-10.0\debug\threading-multi\test_embed.pdb 
...skipped <pbin\test_embed.test\msvc-10.0\debug\threading-multi>test_embed.run for lack of <pbin\test_embed.test\msvc-10.0\debug\threading-multi>test_embed.exe... 
...failed updating 2 targets... 
...skipped 2 targets... 
...updated 6 targets... 

回答

1

我不確定a)的問題是什麼。問題b)似乎是boost示例中的一個錯誤,jam文件試圖從可執行文件而不是靜態lib或cpp文件中生成測試執行文件。

documented what I had to do獲取嵌入示例運行。