【发布时间】:2021-11-14 08:29:26
【问题描述】:
我有这个程序
#include <stdio.h>
#include <mpi.h>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
int size;
int rank;
MPI_Init(NULL, NULL);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
printf("Hello, World!");
cout << MPI_Comm_rank << " " << MPI_Comm_size << endl;
MPI_Finalize();
return 0;
}
当我在 Microsoft Visual Studios 中调试它时,它工作得很好。但是当我在命令提示符或任何终端中尝试时,我得到了这个错误,
Project_1.cpp:2:10: fatal error: mpi.h: No such file or directory
2 | #include <mpi.h>
| ^~~~~~~
compilation terminated.
我已经安装了 g++,它可以与其他程序一起正常工作。我也安装了 MPI。能够将它链接到我的 Microsoft Visual Studio,但它只适用于其调试部分。我正在使用Windows计算机。不太确定该怎么做。任何帮助都会非常感谢。
【问题讨论】:
-
您已将包含路径添加到 Microsoft Visual Studio 的调试设置中 - 您需要在发布配置和任何命令提示符会话中使用相同的信息。
-
您的
cout语句包含两个函数名称。我很惊讶这会起作用,而且它肯定不会给出您期望的输出。 -
@VictorEijkhout:函数的名称将计算为函数的地址。猜测一下,它会被转换为
void *以打印出来。
标签: c++ windows terminal compiler-errors mpi