Undefined reference to vtable

  • Thread starter Matthias Kaeppler
  • Start date
M

Matthias Kaeppler

Hi,

I'm confronted with an error here I haven't encountered before (g++ 3.3.5):

Building duality.elf ...
obj_dbg/mainwindow.o(.gnu.linkonce.t._ZN14TransferDialogC1EN5boost10shared_ptrI4TaskEE+0x5c):
In function
`TransferDialog::TransferDialog[in-charge](boost::shared_ptr<Task>)':
/usr/include/c++/3.3/bits/sstream.tcc:57: undefined reference to `vtable
for TransferDialog'
collect2: ld returned 1 exit status
make: *** [duality.elf] Error 1

It seems to come from this class' ctor:

class TransferDialog: public TaskDialog
{
public:
TransferDialog(TaskPtr task_ptr): TaskDialog(task_ptr) {}
virtual int on_progress_update(
const Gnome::Vfs::Async::Handle&,
Gnome::Vfs::Transfer::progressInfo&);
virtual bool on_progress_sync(
const Gnome::Vfs::Transfer::progressInfo&);
};

here's the base class:

class TaskDialog
{
public:
TaskDialog(TaskPtr task_ptr): task_(task_ptr) {}
virtual ~TaskDialog() {}
virtual int on_progress_update(
const Gnome::Vfs::Async::Handle&,
Gnome::Vfs::Transfer::progressInfo&);
virtual bool on_progress_sync(
const Gnome::Vfs::Transfer::progressInfo&);
protected:
TaskPtr get_task() const;
private:
TaskPtr task_;
};

TaskPtr is merely a typedef for boost::shared_ptr<Task>. I don't think
the Task class matters here, but if you want me to post it I can surely
do that as well.

It almost looks as if a virtual function is being invoked in the ctor
before the vtable exists, but on the other hand, that's not the case, as
far as I can tell. I don't know what is causing this.

Thanks in advance,
Matthias
 
K

Kristo

Matthias said:
Hi,

I'm confronted with an error here I haven't encountered before (g++ 3.3.5):

Building duality.elf ...
obj_dbg/mainwindow.o(.gnu.linkonce.t._ZN14TransferDialogC1EN5boost10shared_ptrI4TaskEE+0x5c):
In function
`TransferDialog::TransferDialog[in-charge](boost::shared_ptr<Task>)':
/usr/include/c++/3.3/bits/sstream.tcc:57: undefined reference to `vtable
for TransferDialog'
collect2: ld returned 1 exit status
make: *** [duality.elf] Error 1

As this is a *linker* error, you're probably better off asking this on
a GCC mailing list. In addition to that, the GCC FAQ
(http://gcc.gnu.org/faq.html#vtables) has an entry that might be of
use.

Kristo
 
G

Gabriel

Matthias said:
Hi,

I'm confronted with an error here I haven't encountered before (g++ 3.3.5):

/usr/include/c++/3.3/bits/sstream.tcc:57: undefined reference to `vtable
for TransferDialog'

That is the most obscure error message the gcc produces, but the reason
is usually simple:

The compiler has to put the vtable into an object file. It puts it into
the object file where the definition of the first non-inline member
function is. If it is missing, you get this rather unhelpful linker
error. Please check the existence of the definitions of your member
functions.

Gabriel
 
M

Matthias Kaeppler

Gabriel said:
The compiler has to put the vtable into an object file. It puts it into
the object file where the definition of the first non-inline member
function is. If it is missing, you get this rather unhelpful linker
error. Please check the existence of the definitions of your member
functions.

Argh, you're right. I didn't provide an implementation for one of the
two methods in the subclass, but I declared it in the subclass. I just
removed the declaration so that the default implementation of the base
class will be used, which is what I want at this point.

Thanks,
Matthias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top