Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Aug 1998 11:22:10 +1000 (EST)
From:      plw@mtiame.mtia.asn.au (Phil Ware)
To:        freebsd-questions@FreeBSD.ORG
Subject:   Linking shared libraries with cyclic dependencies
Message-ID:  <199808140122.LAA00799@mtiame.mtia.asn.au>

next in thread | raw e-mail | index | archive | help
Hello people,

I was attempting to build the qt-1.40 GUI toolkit under FreeBSD and
ran across a few problems; I was wondering if anyone had any ideas.

When linking a shared version of the library, the make process
executes a command something like

ld -Bshareable -o libqt.ao `lorder /usr/lib/c++rt0.o \
	some-very-long-list-of-files-in-subdirectories | tsort` \
	-L/usr/X11R6 -lX11

The lorder ... | tsort mechanism reports a large number of cyclic
dependencies in the object modules, but the library is built.
When I examine the resultant shared library, I find a large number of
external files symbols in it, ie, symbols with names like
kernel/qpsprinter.o with a symbol type of 'F'.

If I link against the shared library the link succeeds, but when I
run the resulting executable I get a message like

ld.so: Cannot load file kernel/qpsprinter.so
(kernel/qpsprinter.o is one of the object files linked into
the shared library).


I then tried building a static version of the library.  It again builds
OK, but if I link against it I get a host of unresolved symbol references
for symbols that are certainly defined in the component object files.
Running ranlib on the static version allows the link to complete
successfully.


Because the ranlib appears to resolve the issue, what I think is happening
is that the cyclic dependencies in the object files mean that not all
symbols in the shared library are being resolved; consequently, the ld.so
is attempting to resolve them at run-time.


Two questions:

1) Is my belief as to the cause of the problem correct ?

2) (The obvious) How do I correct it / work around it.  Reworking the
   object file breakdown to remove cyclic dependencies is not really
   an option given that this is someone else's code.

Sorry for what is really a fairly simple question, but my background
is more the SYSV/COFF/ELF world, where the linker seems to hold your
hand a bit more.

Thanks for any insights,

Phil Ware
plw@mtiame.mtia.asn.au

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199808140122.LAA00799>