bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dependency problem : C++ inheritance & linking...


From: Andrea Pippa
Subject: Dependency problem : C++ inheritance & linking...
Date: Sun, 07 Jul 2002 17:56:41 +0200

Hi! I got a problem in linking an application made with kdevelop. At end
I found out the problem is with ld, and may be more general than this
example...

I have:

libda.a        which contains code of  "class base"
libdb.a        which contains code of  "class child" which is a direct
child of class base.
main.o        which tries to create an instance of class child.

The problem is that linking those, ld complains that from method child()
can't find method base(), which is defined in libda.a.

If I link directly the objects, instead (so use base.o instead libda.a
and child.o instead libdb.a), the linking is correct.
Also, if I use class base directly from main(), it works.

Pratically, what I think it happens, it that ld correctly links child.o
(from libdb.a), but then forgets to find out it's dependencies (so,
forgets to include base.o from libda.a). Instead, if the dependency is
from main.o, base.o from libda.a is correctly included.

Well, it looks quite complicated, but I'm sure if you look 5 seconds at
the code I've included you'll see... note: this code compiles, but if
you go in main() and remove the first line (base a()) you'll find the
error.

I'm currently using ld 2.11.

Hope this can help you... thanks for your attention ! bye !
    Pyper.

Attachment: testerrors.tar.bz2
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]