469,589 Members | 2,109 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,589 developers. It's quick & easy.

Undefined reference to vtable

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._ZN14TransferDialogC1 EN5boost10shared_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
Sep 8 '05 #1
3 194581
Matthias Kaeppler wrote:
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._ZN14TransferDialogC1 EN5boost10shared_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

Sep 8 '05 #2
Matthias Kaeppler wrote:
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
Sep 9 '05 #3
Gabriel wrote:
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

--
Matthias Kaeppler
Sep 9 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Daniel Heiserer | last post: by
3 posts views Thread by bp | last post: by
9 posts views Thread by alessandro | last post: by
7 posts views Thread by Karl Ebener | last post: by
9 posts views Thread by jimjim | last post: by
2 posts views Thread by boyphp | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.