From owner-freebsd-questions Thu Aug 13 18:23:15 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id SAA24413 for freebsd-questions-outgoing; Thu, 13 Aug 1998 18:23:15 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from avatar.mtia.asn.au (melb-gw.mtia.asn.au [203.2.76.66]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id SAA24392 for ; Thu, 13 Aug 1998 18:23:11 -0700 (PDT) (envelope-from plw@mtiame.mtia.asn.au) Received: (from uucp@localhost) by avatar.mtia.asn.au (8.8.8/8.6.9) id LAA19983 for ; Fri, 14 Aug 1998 11:22:41 +1000 (EST) Received: from mtiame.mtia.asn.au(203.2.76.21) by avatar.mtia.asn.au via smap (V2.1) id xma019981; Fri, 14 Aug 98 11:22:30 +1000 Received: by mtiame.mtia.asn.au (SMI-8.6/200.17.1.3) id LAA00799; Fri, 14 Aug 1998 11:22:10 +1000 From: plw@mtiame.mtia.asn.au (Phil Ware) Message-Id: <199808140122.LAA00799@mtiame.mtia.asn.au> Subject: Linking shared libraries with cyclic dependencies To: freebsd-questions@FreeBSD.ORG Date: Fri, 14 Aug 1998 11:22:10 +1000 (EST) X-Mailer: ELM [version 2.4ME+ PL40 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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