Posted by: Andre81
undefined reference to virtual table / type_info function - 25/08/2005 22:18
The C part of my project compiles without a problem but now i've added the cpp files to my project and i get some undefined references for the classes with virtual methods.
For the constructor and destructor i get the linker error
undefined reference to '.... virtual table'
And for the derived classes i get the linker error
undefined reference to '... type_info function' and
undefined reference to '... type_info node'
Any idea?
Posted by: Andre81
Re: undefined reference to virtual table / type_info function - 25/08/2005 22:53
I've found a "solution":
-fno-rtti resolved the following errors
undefined reference to '... type_info function' and
undefined reference to '... type_info node'
Then I've removed the constructor and destructor from the base class which resolved the
undefined reference to '.... virtual table' error.
But actually while the first might be a solution i would like to have my constructor back
Posted by: tman
Re: undefined reference to virtual table / type_info function - 25/08/2005 23:26
You've not implemented the method and it's complaining.
Posted by: wfaulk
Re: undefined reference to virtual table / type_info function - 26/08/2005 13:04
Try compiling the C sources with g++, too. It may be a mangling issue.
Posted by: wfaulk
Re: undefined reference to virtual table / type_info function - 26/08/2005 13:38
Well, the opposite thing to do is to wrap relevant portions of your C++ code with extern C{}, which won't always work, especially if you're using overloading.
My guess is that you're trying to call C++ functions from C and the C object file is expecting to see myfunc() and the C++ object file is providing gnu_int_int_myfunc() or some such nonsense.
Of course, I could be completely off base.
Posted by: wfaulk
Re: undefined reference to virtual table / type_info function - 26/08/2005 13:47
I meant that that may be your initial problem. I understand that C++ doesn't support fork() for whatever reason.
But try including unistd.h.
Posted by: wfaulk
Re: undefined reference to virtual table / type_info function - 26/08/2005 13:59
As Peter said, because gcc is less picky. It assumes that undefined functions return ints, and that's true of fork(). If you give gcc the -Wall flag, it'll complain about that.