Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 无法识别Mpi文件?_C_Ubuntu_Mpi - Fatal编程技术网

C 无法识别Mpi文件?

C 无法识别Mpi文件?,c,ubuntu,mpi,C,Ubuntu,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 (&a

我正试图在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;
}
下面是我尝试编译的任何mpi程序的错误

 gcc: error: mpi_hello.c: No such file or directory

错误消息表示编译器无法找到要编译的文件。由于您检查了文件名,最可能的解释是您没有在文件所在的目录中运行该命令

如果文件位于桌面上,则在运行编译命令之前,应使用类似于
cd~/desktop
的方法将当前目录更改为桌面

如果问题出在MPI的安装上,则错误消息看起来更像

-bash: mpicc: command not found

你的意思肯定是“编译”而不是“运行”?后一个错误是编译错误。您用来编译代码的命令是什么?是的,编译..我使用了这个命令mpicc mpi_hello.c-o hello还请注意,我试图在另一台计算机上编译它,但得到了相同的错误可能看起来像是一个愚蠢的问题,但是您是否在正确的目录中,文件是否确实命名为
mpi_hello.c
?请记住,在Linux上,文件名中的字符大小写确实很重要,如果文件的实际名称类似于
MPI_hello.c
MPI_hello.c
,那么编译器将执行pukeYes操作,我多次检查该文件是否在桌面上,并且其名称与hello.c完全一致,但仍然会出现相同的错误
-bash: mpicc: command not found