[英]Running program with g++ compiler on Ubuntu
I need help with running my program on Ubuntu. 我需要在Ubuntu上运行程序的帮助。 I have two cpp files and a header file.
我有两个cpp文件和一个头文件。 I get the following error.
我收到以下错误。 Can someone help me please.
有人能帮助我吗。
gopy@gopy-VPCEB36GM:~/Desktop/helo$ g++ -c Sequence.cpp
gopy@gopy-VPCEB36GM:~/Desktop/helo$ g++ -c SequenceTest.cpp
gopy@gopy-VPCEB36GM:~/Desktop/helo$ g++ -o Sequence.o SequenceTest.o test
g++: error: test: No such file or directory
The o files are created when I open the helo folder o文件在我打开helo文件夹时创建
g++ man g ++人
-o <file> Place the output into <file>
means test must be right after the -o flag, otherwise linker thinks test is the input 表示test必须在-o标志之后,否则链接器认为test是输入
gopy@gopy-VPCEB36GM:~/Desktop/helo$ g++ -o test Sequence.o SequenceTest.o
尝试
g++ -o test Sequence.o SequenceTest.o
As others have mentioned, -o
stands for output file name. 正如其他人提到的,
-o
代表输出文件名。 In this case, g++ assumes Sequence.o
as the output file name, SequenceTest.o
and test
are the files to be compiled or linked. 在这种情况下,g ++假定
Sequence.o
作为输出文件名, SequenceTest.o
和test
是要编译或链接的文件。 So 所以
g++ -o test Sequence.o SequenceTest.o
is the right way to do this. 是正确的方法。 And, you can do the whole compilation process with a single command.
并且,您可以使用单个命令完成整个编译过程。
g++ Sequence*.cpp -o test
The non-answer is 'sudo apt-get codeblocks'. 非答案是“ sudo apt-get代码块”。 You can spend more time learning C++, and less time mucking with command lines.
您可以花更多的时间学习C ++,而减少使用命令行的时间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.