0

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

  • 5
    I assume the directory you are currently in contains the file "helloworld.cpp"? :p – eltommo Apr 27 '12 at 7:49
4

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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