【发布时间】:2014-01-04 22:13:46
【问题描述】:
我正在尝试在 Ubuntu 上运行一些 mpi 文件我使用此代码安装了库
sudo apt-get install libcr-dev mpich2 mpich2-doc
并尝试运行这个简单的 hello world 程序
/* C Example */
#include <mpi.h>
#include <stdio.h>
int main (int argc, char* argv[])
{
int rank, size;
MPI_Init (&argc, &argv); /* starts MPI */
MPI_Comm_rank (MPI_COMM_WORLD, &rank); /* get current process id */
MPI_Comm_size (MPI_COMM_WORLD, &size); /* get number of processes */
printf( "Hello world from process %d of %dn", rank, size );
MPI_Finalize();
return 0;
}
该库已安装好,但我似乎无法编译任何程序 hello 文件在桌面上
Reading state information... Done
libcr-dev is already the newest version.
mpich2 is already the newest version.
mpich2-doc is already the newest version.
这是我在尝试编译的任何 mpi 程序中不断遇到的错误
gcc: error: mpi_hello.c: No such file or directory
【问题讨论】:
-
你的意思是“编译”而不是“运行”?后一个错误是编译错误。你用什么命令来编译代码?
-
是编译..我用这个命令mpicc mpi_hello.c -o hello
-
另请注意,我尝试在另一台计算机上编译它并得到相同的错误
-
可能看起来像一个愚蠢的问题,但您是否在正确的目录中,文件是否确定命名为
mpi_hello.c?请记住,在 Linux 文件名中的字符大小写确实很重要,如果文件的实际名称类似于MPI_hello.c或Mpi_hello.c,编译器会呕吐 -
是的,我检查了很多次文件在桌面上并准确命名为 hello.c 仍然得到同样的错误