[英]Cannot compile program with MSMPI and GCC
I'm trying to compile a MSMPI program in C with gcc.我正在尝试使用 gcc 用 C 编译 MSMPI 程序。
Here is what I am including in my code:这是我在代码中包含的内容:
#define MSMPI_NO_SAL
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
I'm using Vscode with the following task:我正在使用 Vscode 完成以下任务:
{
"version": "2.0.0",
"tasks": [{
"type": "shell",
"label": "C/C++: gcc.exe build active file",
"command": "C:\\MinGW\\bin\\gcc.exe",
"args": ["-g", "${file}","-I","C:\\Program Files (x86)\\Microsoft SDKs\\MPI\\Lib\\x64","-I","C:\\Program Files (x86)\\Microsoft SDKs\\MPI\\Include", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe"],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
}
}]
}
However, when trying to compile, I get the following error for my code:但是,在尝试编译时,我的代码出现以下错误:
In file included from d:\Documents\1.Ecole\University\Undergrad\Fall 2020\COMP 428\ass1\pi_est_parallel.c:5:
C:\Program Files (x86)\Microsoft SDKs\MPI\Include/mpi.h:4617:5: error: unknown type name '_Out_writes_'; did you mean '_mpi_writes_'?
4617 | _Out_writes_(maxprocs) int array_of_errcodes[]
| ^~~~~~~~~~~~
| _mpi_writes_
C:\Program Files (x86)\Microsoft SDKs\MPI\Include/mpi.h:4629:5: error: unknown type name '_Out_writes_'; did you mean '_mpi_writes_'?
4629 | _Out_writes_(maxprocs) int array_of_errcodes[]
| ^~~~~~~~~~~~
| _mpi_writes_
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command C:\MinGW\bin\gcc.exe -g 'd:\Documents\1.Ecole\University\Undergrad\Fall 2020\COMP 428\ass1\pi_est_parallel.c' -I 'C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64' -I 'C:\Program Files (x86)\Microsoft SDKs\MPI\Include' -o 'd:\Documents\1.Ecole\University\Undergrad\Fall 2020\COMP 428\ass1\pi_est_parallel.exe'" terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
Am I forgetting to include something when compiling?我是否在编译时忘记包含某些内容?
This is a known issue in the Microsoft mpi.h
header file:这是 Microsoft
mpi.h
头文件中的一个已知问题:
The issue references a simple patch adding _Out_writes_
to fix this.该问题引用了一个简单的补丁,添加了
_Out_writes_
来解决这个问题。 You can mirror this in your own code by adding您可以通过添加将其镜像到您自己的代码中
#define _Out_writes_(x)
before you include mpi.h
if you cannot upgrade to the latest version.如果您无法升级到最新版本,则在包含
mpi.h
之前。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.