python - Boost.Python 快速入门链接器错误

标签 python c++ visual-c++ boost boost-python

我只是想按照说明进行操作 here使快速入门示例正常工作。我在 Windows 7 上并尝试使用 MSVC。我安装了 Python 2.7。

我做了什么:

  • 下载 boost_1_57_0.zip 并解压缩到 C:\boost_1_57_0
  • C:\boost_1_57_0 中的命令提示符下,运行:

    bootstrap
    

    然后:

    .\b2
    

    按照 5.1 here 下的说明.在此之后,我收到一条消息说“Boost C++ 库已成功构建!”。

  • C:\boost_1_57_0 添加到我的路径中。说明并没有说要这样做,但由于他们希望我调用 bjam,而这就是它所在的位置,我想我需要这样做。
  • 修改 C:\boost_1_57_0\libs\python\example\quickstart\boost-build.jam 使路径为 boost-build ../../../。 ./tools/build/src ; 而不是 boost-build ../../../../tools/build/v2 ;。这是按照说明 here因为原始路径是错误的,如果您不这样做,bjam 调用将失败。
  • CD 进入 C:\boost_1_57_0\libs\python\example\quickstart 并运行:

    bjam toolset=msvc --verbose-test test
    

首先得到的输出是:

...patience...
...patience...
...found 1926 targets...
...updating 55 targets...
common.mkdir bin
common.mkdir bin\test_ext.test
common.mkdir bin\test_ext.test\msvc-12.0
common.mkdir bin\test_ext.test\msvc-12.0\debug
common.mkdir bin\test_ext.test\msvc-12.0\debug\threading-multi
common.mkdir bin\msvc-12.0
common.mkdir bin\msvc-12.0\debug
common.mkdir bin\msvc-12.0\debug\threading-multi
compile-c-c++ bin\msvc-12.0\debug\threading-multi\extending.obj
extending.cpp
c:\python27\include\pymath.h(22) : warning C4273: 'round' : inconsistent dll linkage
    C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(516) : see previous definition of 'round'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xtgmath.h(190) : warning C4273: '_hypot' : inconsistent dll linkage

接着是一长串其他头文件条目,每个条目都提示不一致的 dll 链接,最后是一堆错误,其中重点包括:

LINK : fatal error LNK1207: incompatible PDB format in 'C:\boost_1_57_0\libs\python\example\quickstart\bin\msvc-12.0\debug\threading-multi\extending.pdb'; delete and rebuild

...failed msvc.link.dll bin\msvc-12.0\debug\threading-multi\extending.pyd bin\msvc-12.0\debug\threading-multi\extending.pdb...
...removing bin\msvc-12.0\debug\threading-multi\extending.pdb

LINK : warning LNK4001: no object files specified; libraries used
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
bin\test_embed.test\msvc-12.0\debug\threading-multi\test_embed.exe : fatal error LNK1120: 1 unresolved externals

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

有什么想法吗?

最佳答案

问题在 1.59 中仍然存在。我已经通过编辑文件设法让 Boost.Build 再次工作:

D:\boost\boost_1_59_0\tools\build\src\tools\msvc.jam

我做了两个改变:

  1. 对此进行更改(第 1351-1355 行):

         generators.register [ new msvc-linking-generator msvc.link.dll :
             OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB IMPORT_LIB :
             <toolset>msvc <suppress-import-lib>false ] ;
         generators.register [ new msvc-linking-generator msvc.link.dll :
             OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB :
             <toolset>msvc <suppress-import-lib>true ] ;
    

    到:

        generators.register [ new msvc-linking-generator msvc.link.dll :
            OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB IMPORT_LIB :
            <toolset>msvc ] ;
    
  2. 删除此行 (#1472):

        toolset.flags msvc.link.dll LINKFLAGS <suppress-import-lib>true : /NOENTRY ;
    

我已经在 Win7 上用 VS2012 和 Python 2.7 测试过了。

关于python - Boost.Python 快速入门链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29053172/

相关文章:

c++ - 从 vector 中读取字符串直到 C++ 中的空格

c++ - 如何在 VC++/MFC 应用程序中根据当前 DPI 设置缩放字体大小?

python - 根据条件将一个数据帧列的值分配给另一数据帧列

python - 使用 Pandas [with key column] 将 CSV 与不同的列组合

c++ - 当我试图通过我的函数打印我的列表时出现段错误

c++ - Informix 中 _int64 的 RFX 等效数据类型

c++ - VC++,与 wxWidgets 链接错误,x64

python - Scipy正常的pdf评估给出了矛盾的值

Python:从(当前已弃用的)位置导入模块时发出警告

c++ - C++11 中的 "No appropriate default constructor available"