symbol
in file
__ls__FR7ostreamRC6String
/var/tmp/cca001BP1.o
cout
/var/tmp/cca001BP1.o
__cl__6Stringii
/var/tmp/cca001BP1.o
length__C6String
/var/tmp/cca001BP1.o
__ls__7ostreamPFR7ostream_R7ostream
/var/tmp/cca001BP1.o
The symbols that are causing the problem are on the left. The list of
files on
right are not really useful to you.
You will notice that the names of the missing symbols have been mangled
to
where you do not recognize the names. To demangle the names you can
use
the 'c++filt' command. for example:
is demangled into: String::length(void) const
% c++filt length__C6String
So now you can tell that the undefined symbol is the method length
that is a
member of the String class.
Now that you know what the symbol is, here are few things to try in
order to fix the problem:
empty definition of a method called Search in the class ListClass that
has an
int return type:
This can be something misspelled, something that has not be properly
declared
(See #Somefile:#:
warning: ANSI C++ forbids declaration 'SomeIdentifi or
#Somefile:#:
'SomeIdentifier' undeclared (first use this functio ), something
could be typed in the wrong order.
There are various things that can be wrong here, but for the most part
it should
be a problem that is local to that line #.
Typically this error appears when you trying to declare an identifier
to be
a type of one of your classes, and the compiler is not aware of your
class name
when it encounters the identifier.
Here are some suggestions for fixing this problem:
This error could result from this error #Somefile:#:
warning: ANSI C++ forbids declaration 'SomeIdentifi , just fix the
preceding error and the problem will most
likely go away. Another possibility is that you simply forgot to declare
the variable or function, and just put add the declaration to the appropriate
part of the file Somefile.
Finally there is a really tricky possibility. This is where the identifier
is actually a data member of a class. In this case, check the declaration
for the function in which this problem pops up in: you are looking
for mispellings, the fact that the function definition is a free function
definition vs a member function definition(remember only member functions
can see private class members).
There are more complex situations where you are using multiple .cc
files and .h
files in your program. And if everything is spelled properly, then
you may want
to look at #includes and make sure you are including the .h file where
the
declaration should be explicitly done.
There are a plethora of things that could be wrong:
Most of the time, either line X or Y is a #include statement,
and that is where
you will find the other definition.
Simply stated:
if (OldType == NewType) && (AnothaOldType != OldType) then
it follows that AnothaOldType != NewType.
An example:
SortedListClass.h:9: conflicting types for `typedef struct listNode
* ptrType'
StackP.h:10: previous declaration as `typedef struct stackNode * ptrType'
Notice how both the pointers struct listNode and structstackNode
are being
called ptrType. This is not legal.