From owner-freebsd-questions Thu Feb 29 23:10:00 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id XAA21565 for questions-outgoing; Thu, 29 Feb 1996 23:10:00 -0800 (PST) Received: from ccslinux.dlsu.edu.ph (humprey@linux1.dlsu.edu.ph [165.220.8.15]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id XAA21476 for ; Thu, 29 Feb 1996 23:07:04 -0800 (PST) Received: (from humprey@localhost) by ccslinux.dlsu.edu.ph (8.6.12/8.6.9) id PAA01431; Fri, 1 Mar 1996 15:03:24 +0800 Date: Fri, 1 Mar 1996 15:03:24 +0800 (GMT+0800) From: "Humprey C. Sy" To: Michael Smith cc: questions@freebsd.org Subject: Re: Compiling with shared libraries In-Reply-To: <199603010608.QAA29879@genesis.atrad.adelaide.edu.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-questions@freebsd.org Precedence: bulk On Fri, 1 Mar 1996, Michael Smith wrote: > > I'm confused about how shared libraries actually work. Here's my > > problem: > > > > I was able to make a shared library file - libmac.a. What I'm confused > > If that's really a shared library, it should be libmac.so.1.0. How > are you building it? If you were using the standard /usr/share/mk > templates it'd be named correctly. I used the bsd.lib.mk template. It produced libmac.a, that's all. What's the difference between .a and .so.X.X files anyway? I thought they're both the same, save for compatibility reasons only. > > about is how come if I have to compile it together with my c program, I > > have to place the option "-lmac" at the end of the command. i.e. > > > > cc -O2 zo.c -lmac > > > > If I try to include "-lmac" before zo.c, the procedures compiled in > > libmac.a won't be seen at all, and the compiler returns errors saying > > these procedures are unreferenced from text segment. Why is this so? > > The linker commandline is read left to right I still don't get the difference. Either way both files will be linked together, so why can't the linker find those procedures in libmac.a if I typed -lmac before zo.c? - Humprey -