[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Newbie KDE/QT Programming question...
From:       Martijn Klingens <mklingens () yahoo ! com>
Date:       2001-07-20 10:40:45
[Download RAW message or body]

And now we're getting somewhere...

On Friday 20 July 2001 12:06, John Toon wrote:
<--- snip --->
> > 4.) Finally you merge 'em: "g++ -o myprog main.o mywindow.o
> > -L$QTDIR/lib - -L$KDEDIR/lib -lkdecore"
>
> Right, if I do that, when I try to execute the newly made executable,
> it reports:
>
> [john1@localhost sillyprog]$ ./myprog
>
>
> FAILURE (KCmdLineArgs):
> Application has not called KCmdLineArgs::init(...).

Hmm, I never used the Qt compatible KApplication constructor, so I don't know 
what's wrong here. But in the mean time you could try the following piece of 
code:

  KAboutData aboutData( "myprog", "MyProg", "Version 0.1" );
  KCmdLineArgs::init( argc, argv, &aboutData );
  KApplication app;

This creates a very basic KAboutData and KCmdLineArgs object. I think your 
approach should be get to work as well, but I don't know how, and with this 
you can at least get it to work.

> And if I instead try compiling it with "g++ -o myprog main.o mywindow.o
> - -L$QTDIR/lib -lqt" (as per the book) it just reports:
>
> [john1@localhost sillyprog]$ g++ -o myprog main.o mywindow.o
> - -L$QTDIR/lib -lqt
> main.o: In function `main':
> main.o(.text+0x3a): undefined reference to
> `KApplication::KApplication(bool, bool)'
> main.o(.text+0x119): undefined reference to
> `KApplication::~KApplication(void)'
> main.o(.text+0x18c): undefined reference to
> `KApplication::~KApplication(void)'
> collect2: ld returned 1 exit status

That's right, because the linker (ld) has a set of .o files that use a class 
KApplication. And libqt.so does _not_ contain that class. The only library 
that does supply this symbol, is the one you just removed from the command 
line, so the linker cannot resolve all the references to KApplication...

> > I can't see why that shouldn't work
>
> Neither can I, which is why I'm baffled :^( What I can't understand is
> that if copying an example _exactly_ from the book it still doesn't
> work. My system is up-to-date (Kernel 2.4.6, XFree86-4.1.0).

Well... there was one typo in the book (void slotButton vs. void 
MyWindow::slotButton), which explains part of the problems. I don't really 
think you should have re-run the moc after fixing this, but maybe that solved 
the problem. Maybe a moc guru can shed some light here?

> Incidentally, my version of g++ is 2.96. Is there some sort of weird
> linker bug going on here? Will upgrading fix it? (I know that gcc is up
> to 3.0 now, so I presume that g++ has also been updated...).

Yes, but 2.96 is actually __much__ better for C++ development than 3.0. In 
fact, artsd cannot be compiled using 3.0 because virtual inheritance breaks. 
Not that that affects 'normal' Qt classes, though. After the first bugfix 
release (in august IIRC) the new gcc can begin to be a serious option.

Martijn
 
>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic