gpt4 book ai didi

c++ - 无法使用 GCC-G++ 包含标准 C++ 库文件

转载 作者:行者123 更新时间:2023-12-03 12:51:04 25 4
gpt4 key购买 nike

我在使用 G++ 编译时遇到包含标准 C++ 库文件的问题这是我尝试编译的代码:

#include <iostream>
int main()
{
return 0;
}

编译时出现错误:

test.cpp:1:20: fatal error: iostream: No such file or directory
#include <iostream>

我不明白为什么......任何提示将不胜感激,谢谢。

编辑:这是我用来编译的命令

g++ -pedantic -Wall -Wextra -std=c++11 test.cpp -o test

编辑:这是使用 -v 编译时的日志任何建议都会很棒...:)

C:\Users\Someone\Desktop>g++ test.cpp -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.8.1/configure --prefix=/mingw --host=mingw32 --build=m
ingw32 --without-pic --enable-shared --enable-static --with-gnu-ld --enable-lto
--enable-libssp --disable-multilib --enable-languages=c,c++,fortran,objc,obj-c++
,ada --disable-sjlj-exceptions --with-dwarf2 --disable-win32-registry --enable-l
ibstdcxx-debug --enable-version-specific-runtime-libs --with-gmp=/usr/src/pkg/gm
p-5.1.2-1-mingw32-src/bld --with-mpc=/usr/src/pkg/mpc-1.0.1-1-mingw32-src/bld --
with-mpfr= --with-system-zlib --with-gnu-as --enable-decimal-float=yes --enable-
libgomp --enable-threads --with-libiconv-prefix=/mingw32 --with-libintl-prefix=/
mingw
Thread model: win32
gcc version 4.8.1 (GCC)
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro'
c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/cc1plus.exe -quiet -v -iprefix c:\min
gw\bin\../lib/gcc/mingw32/4.8.1/ Test.cpp -quiet -dumpbase Test.cpp -mtune=gener
ic -march=pentiumpro -auxbase Test -version -o C:\Users\Gabriel\AppData\Local\Te
mp\ccJCPwY4.s
GNU C++ (GCC) version 4.8.1 (mingw32)
compiled by GNU C version 4.8.1, GMP version 5.1.2, MPFR version 3.1.2,
MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/4.8.1/include/c+
+"
ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/4.8.1/include/c+
+/mingw32"
ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/4.8.1/include/c+
+/backward"
ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/inc
lude/c++"
ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/inc
lude/c++/mingw32"
ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/inc
lude/c++/backward"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/inclu
de"
ignoring nonexistent directory "i:/p/giaw/mingw/include"
ignoring duplicate directory "/mingw/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/inclu
de-fixed"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/../..
/../../mingw32/include"
ignoring duplicate directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
c:\mingw\bin\../lib/gcc/mingw32/4.8.1/include
c:\mingw\bin\../lib/gcc/mingw32/4.8.1/../../../../include
c:\mingw\bin\../lib/gcc/mingw32/4.8.1/include-fixed
c:\mingw\bin\../lib/gcc/mingw32/4.8.1/../../../../mingw32/include
End of search list.
GNU C++ (GCC) version 4.8.1 (mingw32)
compiled by GNU C version 4.8.1, GMP version 5.1.2, MPFR version 3.1.2,
MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: e3b01b00b6cf2cc1dc95350e55dafc7d
Test.cpp:1:20: fatal error: iostream: No such file or directory
#include <iostream>
^
compilation terminated.

最佳答案

我能够通过重新安装 MinGW 解决此问题

关于c++ - 无法使用 GCC-G++ 包含标准 C++ 库文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20307507/

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