Search code examples
c++visual-studio-codemingwdev-c++

Error: g++.exe: No such file or directory g++.exe: fatal error: no input files in Visual studio code?


There is no error in my code, and I have configured Mingw in Environment Variables but showing this error. I've created this file in Dev C++ and is running well in it. The Error is :

g++.exe: error: Calculator: No such file or directory
g++.exe: error: .cpp: No such file or directory
g++.exe: fatal error: no input files
compilation terminated.

I have inserted the image for reference.
enter image description here

Files that I created in Visual studio code are running well and I've tried copying the code of this file in a new file and that ran. So should I do this with all the files I've created with Dev C++ or there is another method to resolve this issue?


Solution

  • Your problem is the filename for your source file is Calculator .cpp which contains a space. This is problematic for languages that use command line compilers like c or c++ because on the command line a space separates arguments so without quotes around the filename your compiler sees Calculator and .cpp as 2 separate files instead of Calculator .cpp. The easy fix for this is to rename the file to remove the space. I highly recommend avoiding spaces in paths or file names with c or c++ regardless of how you build to avoid issues like this.