0

I need help with running my program on Ubuntu. I have two cpp files and a header file. 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

4
  • Also the compiler is GCC, Gnu C(++) Compiler Commented Oct 5, 2013 at 2:52
  • Yeah I have the two o files Commented Oct 5, 2013 at 2:54
  • I would recommend makefiles. Commented Oct 5, 2013 at 5:58
  • Have a look here for a thorough introduction to gcc/g++. Commented Oct 5, 2013 at 6:17

4 Answers 4

3

g++ man

-o <file>                Place the output into <file>

means test must be right after the -o flag, otherwise linker thinks test is the input

gopy@gopy-VPCEB36GM:~/Desktop/helo$ g++ -o test Sequence.o SequenceTest.o
Sign up to request clarification or add additional context in comments.

Comments

2

Try

g++ -o test Sequence.o SequenceTest.o

Comments

1

As others have mentioned, -o stands for output file name. In this case, g++ assumes Sequence.o as the output file name, SequenceTest.o and test are the files to be compiled or linked. 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

Comments

0

The non-answer is 'sudo apt-get codeblocks'. You can spend more time learning C++, and less time mucking with command lines.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.