Date: Tue, 12 Nov 2002 11:45:26 +0100 From: Dag-Erling Smorgrav <des@ofug.org> To: Jonathon McKitrick <jcm@FreeBSD-uk.eu.org> Cc: freebsd-chat@freebsd.org, freebsd-questions@freebsd.org Subject: Re: Unresolved reference compiling Objective-C ?? Message-ID: <xzp65v39id5.fsf@flood.ping.uio.no> In-Reply-To: <20021111234035.GA17831@dogma.freebsd-uk.eu.org> (Jonathon McKitrick's message of "Mon, 11 Nov 2002 23:40:35 %2B0000") References: <20021108173235.GA82490@dogma.freebsd-uk.eu.org> <xzpvg35xza5.fsf@flood.ping.uio.no> <20021111234035.GA17831@dogma.freebsd-uk.eu.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Jonathon McKitrick <jcm@FreeBSD-uk.eu.org> 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-chat" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzp65v39id5.fsf>