Sunday, April 10, 2022

[SOLVED] MinGW cc1plus.exe fatal error (file exists)

Issue

I recently installed a new SSD on my machine, and when I did a clean install of windows I got Visual Studio Code, and was about to get the c++ extension up and running, so I got MinGW, and tried to install the GCC and G++ compilers... And low and behold, after trying a lot of solutions, it is still not working properly on this computer image.

When I try to test the compiler after I got MinGW installed properly, this is what it output:

gcc.exe -Wp,-v -E -xc -dD -x c++ nul
ignoring nonexistent directory 
"c:\mingw\bin\../lib/gcc/mingw32/6.3.0/../../../../mingw32/include"
ignoring duplicate directory 
"c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/include/c++"
ignoring duplicate directory 
"c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/include/c++/mingw32"
ignoring duplicate directory 
"c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/include/c++/backward"
ignoring duplicate directory 
"c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/include"
ignoring duplicate directory 
"/mingw/lib/gcc/mingw32/6.3.0/../../../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../include"
ignoring duplicate directory 
"c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/include-fixed"
ignoring nonexistent directory 
"c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/../../../../mingw32/include"
ignoring duplicate directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include/c++
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include/c++/mingw32
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include/c++/backward
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/../../../../include
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include-fixed
End of search list.
cc1plus.exe: fatal error: nul: No such file or directory
compilation terminated.

Error: 1

The odd part is that the cc1plus.exe is in the MinGW directory, and I even added it to the include path later to see if that would help, and still nothing. I'm not quite sure how to proceed.

This bug has become the bane of my existence for the last week. If anyone has any ideas I'd really appreciate the help. I've had success with MinGW in the past, but for some reason it's giving me problems this time.


Solution

Your commandline is:

gcc.exe -Wp,-v -E -xc -dD -x c++ nul

The error:

cc1plus.exe: fatal error: nul: No such file or directory

is the C++ compiler (cc1plus.exe) telling you that the input file nul does not exist. That will be because there is no file called nul in the current directory.

The Windows CMD NUL device is a virtual device to which the output of a command may be redirected ( command >NUL) to throw it away. It is not a file.

If you want to test that the compiler can be successfully invoked with this commandline, then write a program such as:

main.cpp

int main()
{
    return 0;
}

Save it in the current directory and run:

gcc.exe -Wp,-v -E -xc -dD -x c++ main.cpp


Answered By - Mike Kinghan
Answer Checked By - Timothy Miller (WPSolving Admin)