Don Don - 1 year ago 202
C++ Question

g++ error no such file or directory

I keep getting this error when I try to compile a

file in my unix terminal.

Here is my command:

-bash-4.2$ g++ -o test.cpp test


g++: error: test: No such file or directory
g++: fatal error: no input files
compilation terminated.

But, when I type in


Do I have the wrong version of g++?

Answer Source

Your command line is wrong. Try this

g++ -o test test.cpp

The syntax is -o <output-file>, but you had your input file listed there, so g++ was looking for test as an input file.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download