g ++错误没有这样的文件或目录

时间:2016-10-26 00:18:19

标签: c++ bash unix

当我尝试在我的unix终端中编译.cpp文件时,我一直收到此错误。

这是我的命令:

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

输出:

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

但是,当我输入ls时:

test.cpp

我有错误的g ++版本吗?

1 个答案:

答案 0 :(得分:3)

您的命令行错误。试试这个

g++ -o test test.cpp

语法为-o <output-file>,但您在那里列出了输入文件,因此g ++正在寻找test作为输入文件。

相关问题