[plug] Linking's a bitch!
bburns at erggroup.com
bburns at erggroup.com
Mon May 29 16:25:27 WST 2000
Thanks Mike,
> hang on "Doc"? "View"? .... AAARRRRGGGG! An MFC programmer!!!!
> Begone foul beast!!
Yes, my experience of C++ has been MFC for the last three/four years, this is my
first delve into Linux C++. I don't have the project here at work with me, so
I'll look at it tonight. Mild mannered microserf by day, Linux enthusiast by
night :).
> > ants.o main.o antsview.o -lqt -L/usr/lib -lkdeui -lkfm
> Is that link order right? Think about the dependencies. Woulnt the KDE
> libraries depend on the QT, so need to be linked first?
I'll check the order, but I don't know what the link dependencies should be, or
how to find out what they are.
> > /home/ben/ants/ants/antsdoc.cpp:117: undefined reference to
`AntsDoc::setModified(bool)'
> Well that looks simpler - have you defined the function? Wrong arg type?
> > AntsDoc::setModified(bool) are defined in antsdoc.h,
> Way off the mark. Read about declaration vs definition.
No, both are declared and defined inline in the header, but from memory, not
using the inline keyword. Is this legal in Ansi C++?
eg, in antsview.h,
AntsView : QWidget
{
void setModified(bool _m=true) { m_modified = _m; };
};
in antsview.cpp
#include "antsview.h"
AntsView::SomeOtherFunction()
{
};
but I could try moving them to the cpp file anyway I guess.
> 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
to be useful to me. AntsView is a QWidget,
from memory:
class AntsView : public QWidget
{
//otherstuff
};
So it gets rendered by the the QT framework just as QWidget would--> I guess
QWidget is a QPaintDevice, but this doesn't seem right, even to me, as a QWidget
should USE a PaintDevice to render itself, not BE a PaintDevice.
> Well if you want to program in C++, you should read about it.
Virtual Tables have something to do with multiple inheritence. When you inherit
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.
> > /usr/include/qt/qarray.h(.text+0x22): undefined reference to `AntsDoc
virtual table'
> You dont have a vtable in any of the .o files. This depends on the
> compiler, but from memory, it means the first (non-virtual??) member
> function of the class has not been defined. Have you implemented all the
> member functions?
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). Someone also suggested that I ensure that I use virtual
inheritence.
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.
Cheers all,
Ben
bburns at mailop.com
www.bburns.ic24.net
---------------------------- ERG Group --------------------------
The contents of this email and any attachments are confidential
and may only be read by the intended recipient.
-----------------------------------------------------------------
More information about the plug
mailing list