I don't understand this.

Pages: 12
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
Could you post the exact text of the error message. If using a cmd window, you can select and copy the entire contents by the key sequence:
ALT-SPACE    E    S    ENTER


 
ALT-SPACE
(menu should appear)
 
E
(choose Edit)
 
S
(select all text)
 
ENTER
(copy to clipboard)
Here

g++: error: HelloWorld.cpp: No such file or directory
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.
No such file or directory

We presume that you have created a file, written code into it, and saved it with name "HelloWorld.cpp".

What is the name of the file (if not HelloWorld.cpp)?

In which folder did you save the file to?
It is only called main.
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

write like this one



g++ -o HelloWorld.cpp HelloWorld

./HelloWorld

Last edited on
Topic archived. No new replies allowed.
Pages: 12