Linux 在 Ubuntu 上为 mpi.h 设置 G++ 或 ICC

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5762126/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 03:48:08  来源:igfitidea点击:

Setting up G++ or ICC for mpi.h on Ubuntu

linuxg++ubuntu-10.10include-pathicc

提问by Mikhail

I have never done any major programing outside of VS08.

除了 VS08,我从未做过任何主要的编程。

I am trying to compile a program called LAMMPS with either of the two relevant make files. One calls g++ and the other calls icc (Intel's compiler).

我正在尝试使用两个相关的 make 文件中的任何一个来编译一个名为 LAMMPS 的程序。一个调用 g++,另一个调用 icc(英特尔的编译器)。

icc produces this error:

icc 产生此错误:

icc -O -DLAMMPS_GZIP -DMPICH_SKIP_MPICXX -DFFT_FFTW -M write_restart.cpp > write_restart.d write_restart.cpp(15): catastrophic error: cannot open source file "mpi.h" #include "mpi.h"

icc -O -DLAMMPS_GZIP -DMPICH_SKIP_MPICXX -DFFT_FFTW -M write_restart.cpp > write_restart.d write_restart.cpp(15): 灾难性错误:无法打开源文件“mpi.h”#include“mpi.h”

and g++ throws this error

和 g++ 抛出这个错误

g++ -g -O -DLAMMPS_GZIP -DMPICH_SKIP_MPICXX -DFFT_FFTW -M verlet.cpp > verlet.d pointers.h:25: fatal error: mpi.h: No such file or directory compilation terminated.

g++ -g -O -DLAMMPS_GZIP -DMPICH_SKIP_MPICXX -DFFT_FFTW -M verlet.cpp > verlet.d pointers.h:25: 致命错误: mpi.h: 没有这样的文件或目录编译终止。

The mpi.h file is located in /usr/lib/openmpi/include

mpi.h 文件位于 /usr/lib/openmpi/include

It is my understanding that I need to set that $PATH variable which reads

我的理解是我需要设置读取的 $PATH 变量

bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/opt/intel/bin:/usr/lib/openmpi/include:

bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/opt/intel/bin:/usr/lib /openmpi/包括:

and $LD_LIBRARY_PATH which currently reads

和 $LD_LIBRARY_PATH 当前读取

/usr/lib/openmpi/lib:

/usr/lib/openmpi/lib:

SO, how does one include the mpi.h file? So that either icc or g++ find it?

那么,如何包含 mpi.h 文件?以便 icc 或 g++ 找到它?

采纳答案by Mikhail

Okay, so I got it to work with g++ when setting up cc as "mpic++.mpich2" instead of "mpic++"

好的,所以我在将 cc 设置为“mpic++.mpich2”而不是“mpic++”时让它与 g++ 一起工作

回答by Wirawan Purwanto

mpi.h is a header for MPI library. That would be included if you use mpic++ MPI compiler wrapper instead of g++ in your makefile. mpic++ will call the appropriate compiler. From what you describe you have openmpi package installed on your ubuntu machine.

mpi.h 是 MPI 库的头文件。如果您在 makefile 中使用 mpic++ MPI 编译器包装器而不是 g++ ,则将包括在内。mpic++ 将调用适当的编译器。根据您的描述,您的 ubuntu 机器上安装了 openmpi 软件包。

For more info, you need to consult the manual, e.g.

有关更多信息,您需要查阅手册,例如

http://lammps.sandia.gov/doc/Section_start.html#2_2(for LAMMPS)

http://lammps.sandia.gov/doc/Section_start.html#2_2(对于 LAMMPS)

and perhaps you need to see openmpi manual as to how to set up additional compiler. Not sure if this can be done after openmpi itself has been built. By default I think in Ubuntu openmpi compiler wrappers would only call g++. CMIIW.

也许您需要查看 openmpi 手册以了解如何设置额外的编译器。不确定这是否可以在 openmpi 本身构建后完成。默认情况下,我认为在 Ubuntu openmpi 编译器包装器只会调用 g++。CMIIW。

回答by Tárcius

you can try compile using openmpi make file in /src/MAKE make openmpi

您可以尝试使用 /src/MAKE make openmpi 中的 openmpi make 文件进行编译

in my case, this option was successful

在我的情况下,这个选项是成功的