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
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.
.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
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
.