使用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解决此问题

07-28 00:35