g++: fatal error: cannot execute ‘cc1plus‘: CreateProcess: No such file or directory

问题

在MSYS2 MinGW 64-bit shell中编译一个项目时出现错误提示:

=====
g++: fatal error: cannot execute 'cc1plus': CreateProcess: No such file or directory
compilation terminated.

调查

这和之前遇到的另一个No such file or directory问题很像。
根据之前的经验检查:

$ where gcc
D:\msys64\mingw64\bin\gcc.exe
D:\msys64\usr\bin\gcc.exe

可以看到系统中有两个gcc版本,有可能是这两个冲突导致的。
我实际上还安装了mingw-w64-i686-gcc,不过由于是在MinGW 64-bit环境就没有显示出来。

解决方案

$ pacman -Qo /usr/bin/gcc.exe
/usr/bin/gcc.exe is owned by gcc 11.3.0-3

$ pacman -Ru gcc

将msys版本的gcc卸载掉,问题就解决了。

猜你喜欢

转载自blog.csdn.net/feiyunw/article/details/129863528
今日推荐