I'm running MinGW on windows XP SP3. I wrote a simple program in C++ and saved it as a .cpp file. When I tried to compile it in MinGW at the correct directory a message appeared saying " Error: No such file or directory exists" but I know its in the correct directory.
This is what I typed into MinGW
cd C:\MinGW test # Where I saved the .cpp file
g++ test.cpp -o test.exe
After that an error appears.
Also I did change the Environment Settings path to C:\MinGW\bin
Windows is complaining that the mingw compiler (g++) is not in the path.
Add it to your path by going to Control Panel-> System-> Advanced System Settings -> Advanced -> Environment Variables
Look for the PATH variable and edit it. At the end add a semicolon separater and then the correct path to the MingW bin folder. Then close, then reopen your command prompt. If you now type g++ by itself it should complain that you have no input files. Then use the command you tried previously.
cd C:\MinGW test
does not look right.Did you mean
cd C:\MinGW\test\
?Also remember that you have to separately change into the
C:
drive before performingcd
. What does your prompt say? It'll tell you what directory you're in.To get it to work, you should run the compiler from the folder where the program is, not where MinGW is. First, you need to set your PATH to include MinGW. You can do this with
set PATH = C:\MinGW\bin;%PATH%
on the command line.Then,
cd
to where the program is located and rung++ test.cpp -o test.exe
to compile, andtest
to run.Hope this helps!