" _ompi_mpi_int"在Funktion"_main"中LNK2019 [英] "_ompi_mpi_int" in Funktion "_main" LNK2019

查看:70
本文介绍了" _ompi_mpi_int"在Funktion"_main"中LNK2019的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I was trying to compile mpi_prime.c with openmpi on windows. I tried it with the 32bit and 64bit version of OpenMPI_v1.6.2. I got these outputs.

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

当然,符号当然是未解析的对外部符号的引用"

EDIT : Verweis auf nicht aufgelöstes externes Symbol means of course "unresolved reference to external symbol"

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

So I guess it had something to do with a 32bit vs. 64bit library problem using the wrong .dll as the 32bit version seems to produce less conflicts.

我的计划如下:

  1. 让它在32位上运行->我现在在这里
  2. 让它在64位上运行
  3. 使其与其他编译器(例如gcc)一起运行
  4. 让它与我的IDE代码块一起运行

推荐答案

用于Windows的二进制Open MPI发行版附带以DLL集形式构建的库.提供的.lib文件只是这些DLL的导入库.从DLL调用函数时,其原型必须带有__declspec(dllimport)扩展存储类属性,以允许编译器生成稍有不同的代码来调用此类函数或访问导出的变量.具有dllimport storage-class属性的函数的名称也带有_imp_前缀.没有dllimport,例如对于MPI_Init,编译器会生成对_MPI_Init符号的引用,而库实际上会导出_imp_MPI_Init,从而导致未解决的符号错误.

The binary Open MPI distribution for Windows ships with the library built as set of DLLs. The provided .lib files are simply import libraries for those DLLs. When calling functions from DLLs, their prototypes have to carry the __declspec(dllimport) extended storage-class attribute in order to allow the compiler to generate a slightly different code to call such functions or to access exported variables. Also functions with the dllimport storage-class attribute have their names prefixed with _imp_. Without dllimport, e.g. for MPI_Init, the compiler generates reference to the _MPI_Init symbol while the library actually exports _imp_MPI_Init, hence resulting in an unresolved symbol error.

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

Since Open MPI could be compiled either as a set of static libraries or as a set of DLLs, it uses a simple preprocessor mechanism to handle both cases with a single set of header files (e.g. mpi.h). If the preprocessor symbol OMPI_IMPORTS is defined, all MPI function prototypes get the dllimport treatment and do not get it otherwise. The same is true for the function prototypes from the ORTE and OPAL frameworks, with the corresponding preprocessor symbols being ORTE_IMPORTS and OPAL_IMPORTS.

要使代码与二进制Open MPI发行版一起编译,应将OMPI_IMPORTS添加到预处理器定义列表中,该列表可在项目的设置中找到: Configuration Properties -> C/C ++ -> 预处理器-> 预处理器定义.

To get your code to compile with the binary Open MPI distribution, you should add OMPI_IMPORTS to the list of preprocessor definitions, which could be found in the project's settings: Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions.

这篇关于" _ompi_mpi_int"在Funktion"_main"中LNK2019的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆