Linker &引用_ompi“mpi int”;在Funktion”中_“主要”;LNK2019

Linker &引用_ompi“mpi int”;在Funktion”中_“主要”;LNK2019,linker,linker-errors,openmpi,Linker,Linker Errors,Openmpi,我试图在windows上使用openmpi进行编译。我用32位和64位版本的OpenMPI_v1.6.2进行了尝试。我得到了这些输出 编辑:Verweis auf nicht aufgelöstes externes符号当然意味着“未解析的外部符号引用” 因此,我想这与32位与64位库的问题有关,使用错误的.dll,因为32位版本产生的冲突似乎较少 我的计划是: 让它运行在32位->我现在在这里 让它在64位上运行 使用另一个编译器运行它,例如gcc 让它与我的IDE代码块一起运行 Window

我试图在windows上使用openmpi进行编译。我用32位和64位版本的OpenMPI_v1.6.2进行了尝试。我得到了这些输出

编辑:Verweis auf nicht aufgelöstes externes符号当然意味着“未解析的外部符号引用”

因此,我想这与32位与64位库的问题有关,使用错误的.dll,因为32位版本产生的冲突似乎较少

我的计划是:

  • 让它运行在32位->我现在在这里
  • 让它在64位上运行
  • 使用另一个编译器运行它,例如gcc
  • 让它与我的IDE代码块一起运行

  • Windows的二进制开放MPI发行版附带了作为DLL集构建的库。提供的
    .lib
    文件只是这些DLL的导入库。当从DLL调用函数时,它们的原型必须带有
    \u declspec(dllimport)
    扩展存储类属性,以便编译器生成稍微不同的代码来调用此类函数或访问导出的变量。另外,具有
    dllimport
    存储类属性的函数的名称前缀为
    \u imp
    。如果没有
    dllimport
    ,例如对于
    MPI_Init
    ,编译器将生成对
    \u MPI_Init
    符号的引用,而库实际导出
    \u imp\u MPI_Init
    ,从而导致未解决的符号错误

    由于OpenMPI可以编译为一组静态库或一组DLL,因此它使用一个简单的预处理器机制,用一组头文件(例如
    MPI.h
    )处理这两种情况。如果定义了预处理器符号
    OMPI_IMPORTS
    ,则所有MPI函数原型都会得到
    dllimport
    处理,否则不会得到它。对于来自ORTE和OPAL框架的函数原型也是如此,相应的预处理器符号是
    ORTE\u IMPORTS
    OPAL\u IMPORTS


    要使用二进制开放MPI发行版编译代码,您应该将
    OMPI\u IMPORTS
    添加到预处理器定义列表中,可以在项目的设置中找到:配置属性->C/C++->预处理器->预处理器定义。

    尝试向预处理器定义中添加
    OMPI_IMPORTS
    (在配置属性->C/C++->预处理器->预处理器定义中找到)你愿意回答这个问题,这样我就可以接受了吗?稍后我会写一个较长的答案,并附上适当的参考资料。很高兴这有帮助。
    Microsoft (R) C/C++-Optimierungscompiler Version 17.00.61030 für x86
    Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
    
    mpi_prime.c
    Microsoft (R) Incremental Linker Version 11.00.61030.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    
    /out:mpi_prime.exe
    /LIBPATH:C:\Entwicklung\OpenMPI_v1.6.2-x64/lib
    libmpi_cxx.lib
    libmpi.lib
    libopen-pal.lib
    libopen-rte.lib
    advapi32.lib
    Ws2_32.lib
    shlwapi.lib
    mpicxx mpi_prime.c
    Microsoft (R) C/C++-Optimierungscompiler Version 17.00.61030 für x86
    Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
    
    mpi_prime.c
    Microsoft (R) Incremental Linker Version 11.00.61030.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    /out:mpi_prime.exe
    /LIBPATH:C:\Entwicklung\OpenMPI_v1.6.2-x64/lib
    libmpi_cxx.lib
    libmpi.lib
    libopen-pal.lib
    libopen-rte.lib
    advapi32.lib
    Ws2_32.lib
    shlwapi.lib
    mpi_prime.obj
    mpi_prime.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_MPI_Comm_rank" in Funktion "_main".
    mpi_prime.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_MPI_Comm_size" in Funktion "_main".
    mpi_prime.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_MPI_Finalize" in Funktion "_main".
    mpi_prime.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_MPI_Init" in Funktion "_main".
    mpi_prime.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_MPI_Reduce" in Funktion "_main".
    mpi_prime.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_MPI_Wtime" in Funktion "_main".
    mpi_prime.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_ompi_mpi_comm_world" in Funktion "_main".
    mpi_prime.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_ompi_mpi_op_max" in Funktion "_main".
    mpi_prime.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_ompi_mpi_op_sum" in Funktion "_main".
    mpi_prime.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_ompi_mpi_int" in Funktion "_main".
    mpi_prime.exe : fatal error LNK1120: 10 nicht aufgelöste Externe
    
    Microsoft (R) C/C++-Optimierungscompiler Version 17.00.61030 für x86
    Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
    
    mpi_prime.c
    Microsoft (R) Incremental Linker Version 11.00.61030.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    /out:mpi_prime.exe
    /LIBPATH:C:\Entwicklung\OpenMPI_v1.6.2-win32/lib
    libmpi.lib
    libopen-pal.lib
    libopen-rte.lib
    advapi32.lib
    Ws2_32.lib
    shlwapi.lib
    mpi_prime.obj
    mpi_prime.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_ompi_mpi_comm_world" in Funktion "_main".
    mpi_prime.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_ompi_mpi_op_max" in Funktion "_main".
    mpi_prime.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_ompi_mpi_op_sum" in Funktion "_main".
    mpi_prime.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_ompi_mpi_int" in Funktion "_main".
    mpi_prime.exe : fatal error LNK1120: 4 nicht aufgelöste Externe