Mpi 文件无法识别?

Mpi 文件无法识别?

我正在尝试在 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 文件在桌面上我使用了这个命令

 mpicc mpi_hello.c -o 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

答案1

看来你不在桌面目录中,请尝试移动到桌面并再次编译。

cd ~/Desktop
mpicc mpi_hello.c -o hello 

相关内容