Reputation: 20018
I am trying to compile large C++ project and I am getting this strange error. I know that it is linking error but couldn't figure out what it is exactly.
test_oqlquery.o:(.rodata._ZTV8r_MarrayIhE[vtable for r_Marray]+0x8): undefined reference to r_Marray<unsigned char>::~r_Marray()'
test_oqlquery.o:(.rodata._ZTV8r_MarrayIhE[vtable for r_Marray<unsigned char>]+0xc): undefined reference to
r_Marray::~r_Marray()'
test_oqlquery.o:(.rodata._ZTV8r_MarrayIhE[vtable for r_Marray]+0x28): undefined reference to `r_Marray::print_status(std::basic_ostream >&) const'
What does this error mean ? And, is it possible to see the line number where there error is happening ? How ? I am mainly concerned with what this means
".rodata._ZTV8r_MarrayIhE[vtable for r_Marray]+0x28"
Actually, my error is like this, but dont know why everything inside angle bracket are missing, so replacing them with " ", here is detailed error, it has something to do with template instantiation, as well
test_oqlquery.o:(.rodata._ZTV8r_MarrayIhE[vtable for r_Marray"unsigned char"]+0x8): undefined reference to `r_Marray"unsigned char"::~r_Marray()'
I am using g++ 4.3.3.
Please excuse me, I cannot submit the whole source code here as it is very large and spans over multiple directories.
Thanks a lot.
Upvotes: 0
Views: 595
Reputation: 16549
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?
Upvotes: 4
Reputation: 6295
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.
Upvotes: 6
Reputation: 170509
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.
Upvotes: 2