Compiling C++ code raising "no input files" fatal error?

I am finding it hard to run/compile a simple C++ code in the terminal. Here's the code I am using to compile the file (helloworld.cpp).

g++ helloworld.cpp -o helloworld

I am getting an error. (Image)

g++: fatal error: no input files


Solution 1:

You need to have the code file (in this case helloworld.cpp) in your current working directory. If the code file is in a different directory, you need to specify where in the command. For example

g++ some/other/folder/helloworld.cpp -o helloworld.o