C++ g++;can';找不到标准头(iostream、字符串等)

C++ g++;can';找不到标准头(iostream、字符串等),c++,c++11,C++,C++11,我的测试代码test.cpp: #include <iostream> using namespace std; int main(){ cout<<"hello"<<endl; return 0; } 我的环境: #g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/libexec/gcc/armv7hl-redhat-linux-gnueabi/4.7.2

我的测试代码
test.cpp

#include <iostream>

using namespace std;

int main(){
  cout<<"hello"<<endl;
  return 0;
}
我的环境:

#g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/armv7hl-redhat-linux-gnueabi/4.7.2/lto-wrapper
Target: armv7hl-redhat-linux-gnueabi
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --disable-build-with-cxx --disable-build-poststage1-with-cxx --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,go,lto --enable-plugin --enable-initfini-array --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --disable-sjlj-exceptions --with-cpu=cortex-a8 --with-tune=cortex-a8 --with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16 --with-abi=aapcs-linux --build=armv7hl-redhat-linux-gnueabi
Thread model: posix
gcc version 4.7.2 20121109 (Red Hat 4.7.2-8) (GCC) 
我如何解决这个问题?谢谢你的帮助


好的,这是g++-v测试的结果

Using built-in specs.

COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/armv7hl-redhat-linux-gnueabi/4.7.2/lto-wrapper
Target: armv7hl-redhat-linux-gnueabi
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --disable-build-with-cxx --disable-build-poststage1-with-cxx --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,go,lto --enable-plugin --enable-initfini-array --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --disable-sjlj-exceptions --with-cpu=cortex-a8 --with-tune=cortex-a8 --with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16 --with-abi=aapcs-linux --build=armv7hl-redhat-linux-gnueabi
Thread model: posix
gcc version 4.7.2 20121109 (Red Hat 4.7.2-8) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-march=armv7-a' '-mtune=cortex-a8' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mabi=aapcs-linux' '-mtls-dialect=gnu'
 /usr/libexec/gcc/armv7hl-redhat-linux-gnueabi/4.7.2/cc1plus -quiet -v -D_GNU_SOURCE test.cpp -quiet -dumpbase test.cpp -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=vfpv3-d16 -mabi=aapcs-linux -mtls-dialect=gnu -auxbase test -version -o /tmp/cctwdZCf.s
GNU C++ (GCC) version 4.7.2 20121109 (Red Hat 4.7.2-8) (armv7hl-redhat-linux-gnueabi)
compiled by GNU C version 4.7.2 20121109 (Red Hat 4.7.2-8), GMP version 5.0.5, MPFR version 3.1.1, MPC version 0.9
GGC heuristics: --param ggc-min-expand=85 --param ggc-min-heapsize=104357
ignoring nonexistent directory "/usr/lib/gcc/armv7hl-redhat-linux-gnueabi/4.7.2/../../../../include/c++/4.7.2"
ignoring nonexistent directory "/usr/lib/gcc/armv7hl-redhat-linux-gnueabi/4.7.2/../../../../include/c++/4.7.2/armv7hl-redhat-linux-gnueabi"
ignoring nonexistent directory "/usr/lib/gcc/armv7hl-redhat-linux-gnueabi/4.7.2/../../../../include/c++/4.7.2/backward"
ignoring nonexistent directory "/usr/lib/gcc/armv7hl-redhat-linux-gnueabi/4.7.2/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/armv7hl-redhat-linux-gnueabi/4.7.2/../../../../armv7hl-redhat-linux-gnueabi/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/armv7hl-redhat-linux-gnueabi/4.7.2/include
 /usr/local/include
 /usr/include
End of search list.
GNU C++ (GCC) version 4.7.2 20121109 (Red Hat 4.7.2-8) (armv7hl-redhat-linux-gnueabi)
compiled by GNU C version 4.7.2 20121109 (Red Hat 4.7.2-8), GMP version 5.0.5, MPFR version 3.1.1, MPC version 0.9
GGC heuristics: --param ggc-min-expand=85 --param ggc-min-heapsize=104357
Compiler executable checksum: cab4eacd06fac4cf3a5e1bf6dac7fc2e
test.cpp:1:20: fatal error: iostream: No such file or directory
compilation terminated.
使用内置规格。
收集\u GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/armv7hl redhat linux gnueabi/4.7.2/LTO-WRAPPER
目标:armv7hl redhat linux gnueabi
配置为:../configure--prefix=/usr--mandir=/usr/share/man--infodir=/usr/share/info--with bugurl=http://bugzilla.redhat.com/bugzilla --启用引导--启用共享--启用线程=posix--启用检查=发布--禁用使用cxx的生成--禁用-build-poststage1-with-cxx--使用系统zlib--启用-_xA_atexit——禁用LyBunWrand异常-启用GNU唯一对象-启用链接器构建ID -使用链接器哈希样式= GNU——使能语言= C、C++、Objc、Obj-C++、java、FORTRAN、GO,lto--启用插件--启用initfini数组--启用java awt=gtk--禁用dssi--使用java home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre--启用libgcj多文件--启用java维护器模式--使用ecj jar=/usr/share/java/eclipse-ecj.jar--禁用libjava多库--使用ppl--使用cloog--禁用sjlj异常--使用cpu=cortex-a8--tune=cortex-a8——arch=armv7-a——float=hard——fpu=vfpv3-d16——abi=aapcs-linux——build=armv7hl-redhat-linux-gnueabi
线程模型:posix
gcc版本4.7.2 20121109(红帽4.7.2-8)(gcc)
COLLECT_GCC_OPTIONS='-v'-shared libgcc'-march=armv7-a'-mtune=cortex-a8'-mfloat abi=hard'-mfpu=vfpv3-d16'-mabi=aapcs linux'-mtls方言=gnu'
/usr/libexec/gcc/armv7hl redhat linux gnueabi/4.7.2/cc1plus-quiet-v-D_GNU_SOURCE test.cpp-quiet-dumpbase test.cpp-march=armv7-a-mtune=cortex-a8-mfloat abi=hard-mfpu=vfpvf3-d16-mabi=aapcs linux-mtls方言=GNU-auxbase test-version-o/tmp/cctwdZCf.s
GNU C++(GCC)4.7.2版20121109(红帽4.7.2-8)(ARMV7HL Red Hat Linux GNUEABI)
由GNU C版本4.7.2 20121109(Red Hat 4.7.2-8)、GMP版本5.0.5、MPFR版本3.1.1、MPC版本0.9编制
GGC启发式:--param GGC min expand=85--param GGC min heapsize=104357
忽略不存在的目录“/usr/lib/gcc/armv7hl-redhat-linux-gnueabi/4.7.2/../../../../../../../include/c++/4.7.2”
忽略不存在的目录“/usr/lib/gcc/armv7hl-redhat-linux-gnueabi/4.7.2/../../../../../../include/c++/4.7.2/armv7hl-redhat-linux-gnueabi”
忽略不存在的目录“/usr/lib/gcc/armv7hl redhat linux gnueabi/4.7.2/../../../../../../include/c++/4.7.2/backward”
忽略不存在的目录“/usr/lib/gcc/armv7hl-redhat-linux-gnueabi/4.7.2/include-fixed”
忽略不存在的目录“/usr/lib/gcc/armv7hl-redhat-linux-gnueabi/4.7.2/../../../../../../armv7hl-redhat-linux-gnueabi/include”
#包括“…”搜索从这里开始:
#包括搜索从这里开始:
/usr/lib/gcc/armv7hl-redhat-linux-gnueabi/4.7.2/include
/usr/本地/包括
/usr/包括
搜索列表结束。
GNU C++(GCC)4.7.2版20121109(红帽4.7.2-8)(ARMV7HL Red Hat Linux GNUEABI)
由GNU C版本4.7.2 20121109(Red Hat 4.7.2-8)、GMP版本5.0.5、MPFR版本3.1.1、MPC版本0.9编制
GGC启发式:--param GGC min expand=85--param GGC min heapsize=104357
编译器可执行校验和:cab4eacd06fac4cf3a5e1bf6dac7fc2e
test.cpp:1:20:致命错误:iostream:没有这样的文件或目录
编译终止。

这很可能是由于未安装libstdc++-devel软件包

您的编译器版本表明您正在运行RHEL、CentOS或Fedora。执行以下命令:

yum install libstdc++-devel

这很可能是因为没有安装libstdc++-devel包

您的编译器版本表明您正在运行RHEL、CentOS或Fedora。执行以下命令:

yum install libstdc++-devel

这很可能是因为没有安装libstdc++-devel包

您的编译器版本表明您正在运行RHEL、CentOS或Fedora。执行以下命令:

yum install libstdc++-devel

这很可能是因为没有安装libstdc++-devel包

您的编译器版本表明您正在运行RHEL、CentOS或Fedora。执行以下命令:

yum install libstdc++-devel

运行
g++-v test.cpp
。它应该告诉您它要查找的目录包括哪些。运行
g++-v test.cpp
。它应该告诉您它要查找的目录包括哪些。运行
g++-v test.cpp
。它应该告诉您它要查找的目录包括哪些。运行
g++-v test.cpp
。它应该告诉你它要找的目录是什么。为什么你认为“软件包已经安装了”?发布“rpm-qlibstdc++-devel”命令的输出。软件包是libstdc++-devel,而不是libstdc++。我执行了命令,它说:
package libstdc++-devel-4.7.2-8.fc18.armv7hl已经安装,最新版本无事可做
可能安装已损坏。rpm-q-l libstdc++-devel| grep iostream应该显示此包安装iostream的位置,在您的情况下,它应该是/usr/include/c++/4.7.2。验证它是否存在。如果发现安装已损坏,请使用rpm-e libstdc++-devel删除,然后使用yum install重新安装该软件包。尝试“查找iostream”并查看它是否提供了一些信息。`/usr/include/c++/4.7.2/iostream`存在。我删除了
libstdc++-devel
,但得到一个错误:
失败的依赖项…gcc-c++……
,然后,我删除
gcc-c++
libstdc++-devel
并重新安装。重新测试,但问题仍然存在。感谢您的耐心等待。为什么您认为“软件包已安装”?发布“rpm-qlibstdc++-devel”命令的输出。软件包是libstdc++-devel,而不是libstdc++。我执行了命令,它说:
package libstdc++-devel-4.7.2-8.fc18.armv7hl已经安装,最新版本无事可做
可能安装已损坏。rpm-q-l libstdc++-devel| grep iostream应该显示此包安装iostream的位置,pre