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

question

An error message appears when compiling a project in the MSYS2 MinGW 64-bit shell:

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

investigation

This is very similar to another No such file or directory problem I encountered before .
Check against previous experience:

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

You can see that there are two gcc versions in the system, which may be caused by conflicts between the two.
I actually installed mingw-w64-i686-gcc, but it was not displayed because it was in the MinGW 64-bit environment.

solution

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

$ pacman -Ru gcc

Uninstall the msys version of gcc and the problem will be solved.

Guess you like

Origin blog.csdn.net/feiyunw/article/details/129863528