损坏的编译器:致命错误:_mingw.h:没有这样的文件或目录

损坏的编译器:致命错误:_mingw.h:没有这样的文件或目录

我的编译被破坏了,并且不确定是否有可能在不从头开始重新安装所有内容的情况下修复它。

我无法编译最简单的程序:

#include "math.h"

int main()
{
    return 0;
}

当然,它是在我的备份版本上编译的,但我试图避免恢复到工作版本,因为从那时起我已经安装了很多东西......并且显然在此过程中破坏了一些东西。

从错误来看,编译器似乎正在尝试使用_mingw.h标头。为什么?我没有使用 MinGW。我使用的是与备份版本中相同的编译器,该编译器运行正常(我甚至尝试安装另一个版本以g++确认apt-get更改编译器没有帮助)。错误消息:

 In file included from /usr/local/include/crtdefs.h:10:0,
                  from /usr/local/include/sys/cdefs.h:7,
                  from /usr/include/features.h:424,
                  from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39,
                  from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533,
                  from /usr/include/c++/7/cmath:41,
                  from /usr/include/c++/7/math.h:36,
                  from /mnt/c/test/main.cpp:1: /usr/local/include/corecrt.h:10:10: fatal error: _mingw.h: No such
 file or directory  #include <_mingw.h>
           ^~~~~~~~~~ compilation terminated.

我知道该_mingw.h文件不存在。这不是问题所在。问题g++甚至需要它:在我的备份版本中,此标题也不存在且未包含在内。

g++ -M main.cpp备份版本的输出(请注意它包含的内容/usr/include/x86_64-linux-gnu/sys/cdefs.h而不是/usr/local/include/sys/cdefs.h像损坏的版本)。

main.o: /mnt/c/test/main.cpp /usr/include/stdc-predef.h \
 /usr/include/c++/7/math.h /usr/include/c++/7/cmath \
 /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h \
 /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h \
 /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
 /usr/include/x86_64-linux-gnu/bits/wordsize.h \
 /usr/include/x86_64-linux-gnu/bits/long-double.h \
 /usr/include/x86_64-linux-gnu/gnu/stubs.h \
 /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
 /usr/include/x86_64-linux-gnu/c++/7/bits/cpu_defines.h \
 /usr/include/c++/7/bits/cpp_type_traits.h \
 /usr/include/c++/7/ext/type_traits.h /usr/include/math.h \
 /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
 /usr/include/x86_64-linux-gnu/bits/types.h \
 /usr/include/x86_64-linux-gnu/bits/typesizes.h \
 /usr/include/x86_64-linux-gnu/bits/math-vector.h \
 /usr/include/x86_64-linux-gnu/bits/libm-simd-decl-stubs.h \
 /usr/include/x86_64-linux-gnu/bits/floatn.h \
 /usr/include/x86_64-linux-gnu/bits/floatn-common.h \
 /usr/include/x86_64-linux-gnu/bits/flt-eval-method.h \
 /usr/include/x86_64-linux-gnu/bits/fp-logb.h \
 /usr/include/x86_64-linux-gnu/bits/fp-fast.h \
 /usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h \
 /usr/include/x86_64-linux-gnu/bits/mathcalls.h \
 /usr/include/x86_64-linux-gnu/bits/iscanonical.h \
 /usr/include/c++/7/bits/std_abs.h /usr/include/stdlib.h \
 /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h \
 /usr/include/x86_64-linux-gnu/bits/waitflags.h \
 /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
 /usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
 /usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \
 /usr/include/x86_64-linux-gnu/sys/types.h \
 /usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
 /usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
 /usr/include/x86_64-linux-gnu/bits/types/time_t.h \
 /usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
 /usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \
 /usr/include/x86_64-linux-gnu/bits/endian.h \
 /usr/include/x86_64-linux-gnu/bits/byteswap.h \
 /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
 /usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
 /usr/include/x86_64-linux-gnu/sys/select.h \
 /usr/include/x86_64-linux-gnu/bits/select.h \
 /usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
 /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
 /usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
 /usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
 /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
 /usr/include/x86_64-linux-gnu/bits/sysmacros.h \
 /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
 /usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
 /usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
 /usr/include/alloca.h /usr/include/x86_64-linux-gnu/bits/stdlib-float.h

如果这对问题很重要,我正在使用 WSL2。我没有*mingw*列出任何软件包dpkg --list

相关内容