From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 111c93,9f5c1c8d844fc69e X-Google-Attributes: gid111c93,public X-Google-Thread: 1025b4,9f5c1c8d844fc69e X-Google-Attributes: gid1025b4,public X-Google-Thread: 10d0a1,9f5c1c8d844fc69e X-Google-Attributes: gid10d0a1,public X-Google-Thread: 1125fa,9f5c1c8d844fc69e X-Google-Attributes: gid1125fa,public X-Google-Thread: fcfb9,9f5c1c8d844fc69e X-Google-Attributes: gidfcfb9,public From: mdw@catbert.ebi.ac.uk (Mark Wooding) Subject: Re: DLL mess Re: "No-one gets fired for buying Microsoft" Date: 1999/09/15 Message-ID: #1/1 X-Deja-AN: 525357121 Content-Transfer-Encoding: 8bit References: <37D81FE1.E90C3B1F@winkinc.com> <37e6591c.370733736@news.shore.net> <7rl5b3$bnj$1@mulga.cs.mu.OZ.AU> <37df4efc.433677244@news.shore.net> <37e49171.450690508@news.shore.net> Content-Type: text/plain; charset=iso-8859-1 X-Complaints-To: news@hgmp.mrc.ac.uk X-Trace: niobium.hgmp.mrc.ac.uk 937391392 28140 193.62.196.237 (15 Sep 1999 10:29:52 GMT) Organization: MRC Human Genome Mapping Project Resource Centre Mime-Version: 1.0 User-Agent: slrn/0.9.5.3 (UNIX) Reply-To: mdw@ebi.ac.uk NNTP-Posting-Date: 15 Sep 1999 10:29:52 GMT Newsgroups: comp.os.linux.alpha,comp.os.linux.advocacy,comp.os.ms-windows.advocacy,comp.os.ms-windows.nt.advocacy,gnu.misc.discuss Se�n � Donnchadha wrote: > Not quite. The linker, given "foo", finds "foo.sa", which is simply > the import library for a particular major revision of foo. Depends. With Linux a.out (and allegedly SunOS -- that was before my time), this was true. With ELF, no it ain't. Here's how it *actually* works. You give `-lfoo' as an option to `cc' when you link. `cc' invokes `ld' passing it `-lfoo' and a pile of other arguments. `ld' sees `-lfoo' and tries to find one of `libfoo.so' (shared library, preferable) or `libfoo.a' (static library, less preferable) in certain standard places. Let's say it finds `/usr/lib/libfoo.so'. Now that's actually a symbolic link to `libfoo.so.5.2'[1]. The linker reads the symbol table of the library and resolves references in the executable it's building. It also reads the soname of the library and sticks it in the program's header; the soname is `libfoo.so.5'. When the program runs, the dynamic loader digs through the program's header and tries to find all the libraries it refers to. It finds `libfoo.so.5' and looks in its various directories (specified in the program header, and in the LD_LIBRARY_PATH variable) for a file of this name, and finds one in `/usr/lib'. It again is a symlink to `libfoo.so.5.2'. The library is mapped and symbols are resolved. There aren't any of these bogus `.sa' files lying around. The bad old days of a.out are far behind us. [1] Usually. Sometimes the actual library is called something more bizarre like `libfoo-5.2.so', or the `.so' file is a linker script. Let's ignore these things for now and concentrate on the simple stuff. -- [mdw]