2

Whenever I type in g++ toe.ccp this comes up:

/usr/bin/ld:toe.ccp: file format not recognized; treating as linker script
/usr/bin/ld:toe.ccp:1: syntax error
collect2: ld returned 1 exit status

2 Answers 2

3

It appears you have the wrong file extension. You created a file which you called toe.ccp, however what you want is a file that is toe.cpp (Two p's, not two c's in your file extension). Renaming the file will cause g++ to work correctly.

In case you are unfamiliar with how to do so on the command line, you can do

mv toe.ccp toe.cpp

in the terminal to rename the file. Then try compiling it with g++, it should now work.

1
  • 3
    Another option (in case the poster really needs the suffix to be .ccp for some reason) is to declare the source language explicitly using the -x option e.g. g++ -x c++ toe.ccp Jun 2, 2014 at 20:03
1

You should use the correct file extension for the program. toe.ccp is not recognized by GCC as a source file format because of the file extension, so it doesn't know what to do with it. You probably meant to save your file as toe.cpp instead.

As shown in the GCC user manual section on input file names, there are a predefined list of file extensions for each recognized programming language. C++ source files can end in .cc, .cp, .cxx, .cpp, .CPP, .c++, or .C.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .