Compiling MPI with make, several namespace errors such as "error: unknown type name ‘using’?

Compiling MPI with make, several namespace errors such as "error: unknown type name ‘using’?

我正在尝试在 Xubuntu 16.04 LTS 上编译 MPI,我非常肯定我已经安装了所有 g++ 和 gcc 包含和库,但我遇到了这个奇怪的混乱...

    make[3]: Entering directory '/media/verthex/32gig/openmpi-3.1.2/oshmem/shmem/c/profile'
  LN_S     pshmem_init.c
  CC       pshmem_init.lo
In file included from ../../../../oshmem/include/shmem.h:26:0,
                 from ../../../../oshmem/include/oshmem/constants.h:15,
                 from pshmem_init.c:22:
/usr/local/include/complex.h:10:1: error: unknown type name ‘using’
 using namespace std;
 ^
/usr/local/include/complex.h:10:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘std’
 using namespace std;
                 ^
/usr/local/include/complex.h:13:17: fatal error: cmath: No such file or directory
compilation terminated.
Makefile:1950: recipe for target 'pshmem_init.lo' failed
make[3]: *** [pshmem_init.lo] Error 1
make[3]: Leaving directory '/media/verthex/32gig/openmpi-3.1.2/oshmem/shmem/c/profile'
Makefile:2012: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/media/verthex/32gig/openmpi-3.1.2/oshmem/shmem/c'
Makefile:2578: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/media/verthex/32gig/openmpi-3.1.2/oshmem'
Makefile:1897: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

这是最后的配置输出。

Open MPI configuration:
-----------------------
Version: 3.1.2
Build MPI C bindings: yes
Build MPI C++ bindings (deprecated): no
Build MPI Fortran bindings: no
MPI Build Java bindings (experimental): no
Build Open SHMEM support: yes
Debug build: no
Platform file: (none)

Miscellaneous
-----------------------
CUDA support: no
PMIx support: internal

Transports
-----------------------
Cisco usNIC: no
Cray uGNI (Gemini/Aries): no
Intel Omnipath (PSM2): no
Intel SCIF: no
Intel TrueScale (PSM): no
Mellanox MXM: no
Open UCX: no
OpenFabrics Libfabric: no
OpenFabrics Verbs: yes
Portals4: no
Shared memory/copy in+copy out: yes
Shared memory/Linux CMA: yes
Shared memory/Linux KNEM: no
Shared memory/XPMEM: no
TCP: yes

Resource Managers
-----------------------
Cray Alps: no
Grid Engine: no
LSF: no
Moab: no
Slurm: yes
ssh/rsh: yes
Torque: no

因为,您要编译的文件 pshmem_init.c 显然是 C 文件,而不是 C++ 文件。 make 和编译器都会尝试将以 .c 结尾的文件编译为 C,除非你竭尽全力改变他们的想法。

在我看来 C 文件 pshmem_init.c 包含 header complex.h 意思是访问标准 C header,在 /usr/include/complex.h 中找到,但是您已将同名 (complex.h) 的 C++ header 文件添加到 /usr/local/include 中,并且您已要求编译器首先查看该文件(它将始终查找默认系统目录最后)。

您必须先解决这个问题,然后才能编译此代码。