Dec 13, 2016 at 8:51am UTC
It didn't find it anywhere I even decided to put it in in the D:\> but it keeps saying there is no such file directory.
Last edited on Dec 13, 2016 at 8:56am UTC
Dec 13, 2016 at 10:08am UTC
Here
g++: error: HelloWorld.cpp: No such file or directory
Dec 13, 2016 at 10:54am UTC
We know from this error message that your compiler is actually working! Try changing the file name (but always with the .cpp extension) and/or location and if you have access to any other laptop or PC give it a shot from there as well but I don't see why it shouldn't work under current setup.
Dec 20, 2016 at 6:02pm UTC
If your source file is called
main without a file extension you need to explicitly tell the compiler that it is C++ using the -x option.
g++ -o HelloWorld -x c++ main
If your source file is called
main.cpp the compiler will automatically assume it is C++ based on the file extension.
g++ -o HelloWorld main.cpp
If you want the executable file to have a different name you can substitute HelloWorld with whatever you want.
Last edited on Dec 20, 2016 at 6:06pm UTC
Dec 20, 2016 at 6:37pm UTC
write like this one
g++ -o HelloWorld.cpp HelloWorld
./HelloWorld
Last edited on Dec 20, 2016 at 6:37pm UTC