views:

373

answers:

3
+2  A: 

This typically happens if you have declared a method but haven't provided or haven't linked its implementation.

For example you have

class r_Marray {
public:
    ~r_Marray();
};

and you intended to provide the implementation of r_Marray::~r_Marray() in file r_Marray.cpp but forgot to do it - it will compile fine but not link with the error you see. Or you could have provided the implementation but not include the file with that implementation into the input of the linker.

sharptooth
+4  A: 

Either you have not defined r_Marray::~r_Marray() and r_Marray::print_status or the cpp file containing these methods were not part of your build process.

If you do have the cpp file with these methods defined, please post your Makefile.

Based on your comment to your question I am assuming that r_Marray is templated class? Do you have the definitions for the r_Marray methods in your header file?

Jesse
+5  A: 

First, linker errors and compiler errors are different things. Since linker deals with object files rather than source files, compiler errors have a line number but linker errors don't.

Second, it seems that you have declared the destructor for r_Marray but have not implemented it anywhere included in the build. The same thing goes for print_status.

erelender
Another common reason for link errors like this is incorrect linking order. For example, if print_status and destructor are defined in libMarray.a, then 'g++ -lMarray test_oldquery.o' would produce such an error.
Employed Russian