From owner-freebsd-questions Tue Nov 12 2:45:33 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 097F937B401; Tue, 12 Nov 2002 02:45:32 -0800 (PST) Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id E38D643E42; Tue, 12 Nov 2002 02:45:29 -0800 (PST) (envelope-from des@ofug.org) Received: by flood.ping.uio.no (Postfix, from userid 2602) id 4A70A534E; Tue, 12 Nov 2002 11:45:27 +0100 (CET) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: Jonathon McKitrick Cc: freebsd-chat@freebsd.org, freebsd-questions@freebsd.org Subject: Re: Unresolved reference compiling Objective-C ?? References: <20021108173235.GA82490@dogma.freebsd-uk.eu.org> <20021111234035.GA17831@dogma.freebsd-uk.eu.org> From: Dag-Erling Smorgrav Date: Tue, 12 Nov 2002 11:45:26 +0100 In-Reply-To: <20021111234035.GA17831@dogma.freebsd-uk.eu.org> (Jonathon McKitrick's message of "Mon, 11 Nov 2002 23:40:35 +0000") Message-ID: Lines: 31 User-Agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2 (i386--freebsd) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Jonathon McKitrick writes: > On Sun, Nov 10, 2002 at 03:41:38PM +0100, Dag-Erling Smorgrav wrote: > | In other words: always specify libraries at the end of the compiler or > | linker command line. > So why allow putting them at the beginning, where mistakes like this can > happen? Is that ever useful? Would it be wrong to 'assume' all libraries > be linked after all object files? It is conceivable that a high-level application framework would define main and require the developer to define some other entry point which main would then call. In that case you'd have to put the library that contains main first. The point is that there is no real difference between foo.c, foo.s, foo.o, foo.a, -lfoo etc., they're just different ways of telling the compiler where to find the objects your program consists of (in the first two cases it has to create the object itself from source code). The only thing special about -lfoo is that it tells the compiler to look for libfoo.a or libfoo.so in the linker path and use the first one it finds. You could use /usr/local/lib/libfoo.so instead of -lfoo and it would work just as well. Also, if some symbols your program needs are defined in more than one of the objects listed on the linker command line, the ordering becomes very important because it determines which version of the symbol is used (unless one is strong and all the others are weak, in which case the strong version is used) DES -- Dag-Erling Smorgrav - des@ofug.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message