C ++预处理器“ / lib / cpp”未通过健全性检查


21

我需要编译HDF5,并且在配置过程后,我收到此错误:

configure: error: C++ preprocessor "/lib/cpp" fails sanity check

我知道我已经cpp安装了ubuntu

任何帮助将不胜感激:)这是输出 dpkg --list | grep compiler

ii  gcc                                                        4:4.8.2-1ubuntu6                                    amd64        GNU C compiler
ii  gcc-4.8                                               4.8.2-19ubuntu1                                     amd64        GNU C compiler
ii  gfortran                                              4:4.8.2-1ubuntu6                                    amd64        GNU Fortran 95 compiler
ii  gfortran-4.8                                          4.8.2-19ubuntu1                                     amd64        GNU Fortran compiler
ii  hardening-includes                                    2.5ubuntu2                                          all          Makefile for enabling compiler flags for security hardening
ii  libllvm3.4:amd64                                      1:3.4-1ubuntu3                                      amd64        Modular compiler and toolchain technologies, runtime library
ii  libxkbcommon0:amd64                                   0.4.1-0ubuntu1                                      amd64        library interface to the XKB compiler

这是我收到的错误:

  nazanin@barashka:~/hdf5-1.8.13$ ./configure --with-zlib=/home/nazanin/local    --prefix=/home/nazanin/local
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking shell variables initial values... done
checking if basename works... yes
checking if xargs works... yes
checking for cached host... none
checking for config x86_64-unknown-linux-gnu... no
checking for config x86_64-unknown-linux-gnu... no
checking for config unknown-linux-gnu... no
checking for config unknown-linux-gnu... no
checking for config x86_64-linux-gnu... no
checking for config x86_64-linux-gnu... no
checking for config x86_64-unknown... no
checking for config linux-gnu... found
compiler 'gcc' is GNU gcc-4.8.2
checking for config ./config/site-specific/host-barashka... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking if unsupported combinations of configure options are allowed... no
checking if Fortran interface enabled... no
checking if Fortran 2003 interface enabled... yes
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking dependency style of g++... none
checking how to run the C++ preprocessor... /lib/cpp
configure: error: in `/home/nazanin/hdf5-1.8.13':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details

我需要在这里复制config.log吗?谢谢


请在上方和下方显示一些行!
Volker Siegel

骗你输出的结果dpkg --list | grep compiler
AlexGreg 2014年

Answers:


24

如果您的配置输出与此类似,则说明缺少C ++编译器:

[ ... ]
*** C++ compiler and preprocessor
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking dependency style of g++... none
checking how to run the C++ preprocessor... /lib/cpp
configure: error: in `/home/ubuntu/.local/share/Trash/files/openmpi-1.4.1':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details.


要安装GNU C ++编译器,请使用
apt-get install g++


configure输出显示./configure试图通过一个接一个地检查许多已知的编译器名称来查找C ++编译器。
在开始时,我们看到g++缺少-首选,首先检查。
但是它继续尝试寻找您可能更喜欢使用的其他编译器。


21

在centos 7上安装protobuf-2.5.0的过程中出现类似类型的错误,为此我必须通过命令安装gcc-c ++-

 yum install gcc-c++

2
yum是其他Linux发行版的软件包管理器,此处不再讨论。Ubuntu使用Apt。
David Foerster'8

11
我只是大声叫喊,谷歌把我带到了这里,他的回答仍然很有帮助。
Shadoninja '16

3
谢谢您的回答,即使在技术上是题外话。帮助我。
Ed Daniel

2
谢谢。这省去了我在Amazon Linux计算机上安装PHP 7.0的麻烦。
马科斯·里吉斯

2

我的解决方案是在/ lib / cpp上建立一个指向gcc的符号链接。

ln -sv "$(which gcc)" /lib/cpp


1

将其放在您的环境中可能会达到目的:

GCC_PATH=#add the root directory to the gcc installation
export CPPFLAGS=-I$GCC_PATH/include/c++/5.3.0:$CPPFLAGS

如果它有效,则意味着您要使用的gcc版本与尝试包含的gcc版本之间存在库冲突。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.