Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)

enter image description here

share|improve this question
I assume the directory you are currently in contains the file "helloworld.cpp"? :p – eltommo Apr 27 '12 at 7:49
up vote 3 down vote accepted

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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.