[plug] Linking's a bitch!

Mike Holland myk at golden.wattle.id.au
Tue May 30 12:03:07 WST 2000


summary: looks like a template problem.

On Mon, 29 May 2000 bburns at erggroup.com wrote:

> I'll check the order, but I don't know what the link dependencies should be, or
> how to find out what they are.

That could explain it.

> No, both are declared and defined inline in the header, but from memory, not
> using the inline keyword.  Is this legal in Ansi C++?

OK, I guess thats both declaration and definition then.

>      AntsView : QWidget

Thats a different class. Is AntsDoc the same?

> > Isnt AntsView your class? How can a subclass "AntsView::QPaintDevice" be
> > in the QT library then? Why are you subclassing?
> 
> Actually, AntsView is part of the QT framework - it looked similar enough to MFC

Huh? What is "part of the QT framework" ? I dont see it in libqt.
  Aren't you writing the class, inheriting from a QT class?

> So it gets rendered by the the QT framework just as QWidget would--> I guess

What does "rendered" mean? This is not a C++ term I've ever heard.

> Virtual Tables have something to do with multiple inheritence.

Just inheritance - not necessarily multiple.

> from a superclass you can use the keyword virtual --> which means that if
> another class inherits from yours and the one that your class inherited from, it
> only ends up with one copy of the superclass.  The virtual tables map the
> interfaces of each class in your class hierachy to a single function.  Am I
> close or just babbling bollocks?  I've never had to really deal
> with them before.

Sounds about right. Multiple inheritence can get horribly complex. I can
see why java ditched it in favour of "interfaces" - much neater.
   Are you actually using multiple inheritence or virtual subclasses?
 
> > > /usr/include/qt/qarray.h(.text+0x22): undefined reference to `AntsDoc
> virtual table'

Ahah! I see now. This is a _template_ problem. Bingo. A template cant use
inline functions. Try explicitly making the functions non-inline. The
compiler should do this, but there must be other problems.
Inline functions cant be in a vtable, so cant be virtual. Are you trying
to override base class f'ns with inlines?

 This is getting a bit technical for PLUG. There dont seem to be many
programmers here. Anyone interested?? maybe a C++ newsgroup?
How about posting a http or ftp URL to the source, rather than spending
time on a long Q-A exchange?

> I'll look for non implemented member functions again.  I would have thought
> though, that as it compiled --> I at least have the declaration of all
> functions, if not the defintion, and that the linker would have given me the
> name of the function it couldn't find a definition for (as in isModified and
> setModified).

Only if they are referenced. C++ compilers do all sorts of weird tricks
with templates and vtables. Different compilers have different ways.
The old compile-link model comes from C, and is a total hack/mess in C++.

>  Someone also suggested that I ensure that I use virtual
> inheritence.

Why?

> If your interested, this is the AntsPortation project I'm working on.  I wrote
> ants as a something to do while extremely bored, but its only available for
> 'that other OS'.  I'm porting it to Linux and GPLing it --> but I can think of
> no commercial or practical use for it, it's just been a learning tool for me.
> You can get the other OS version of it from www.bburns.ic24.net, but its pretty
> boring really.

An "ant simulation"! You've got me interested ....
Whoa! Just "ants.exe". Wheres the source Luke? 


Mike Holland  <mike at golden.wattle.id.au>
                          --==--




More information about the plug mailing list