gpt4 book ai didi

c++ - g++ 找不到标准 header (iostream、字符串等)

转载 作者:行者123 更新时间:2023-11-28 00:19:13 26 4
gpt4 key购买 nike

我的测试代码test.cpp:

#include <iostream>

using namespace std;

int main(){
cout<<"hello"<<endl;
return 0;
}

当我通过 g++ test.cpp 编译它时,我收到以下错误:

fatal error: iostream: No such file or directory

我的环境:

#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)

我该如何解决这个问题?感谢您的帮助。


ok,这就是g++ -v test.cpp

的结果
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.

最佳答案

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

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

yum install libstdc++-devel

关于c++ - g++ 找不到标准 header (iostream、字符串等),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28422781/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com