Date: Wed, 27 Nov 1996 17:08:46 +0100 (MET) From: Greg Lehey <grog@lemis.de> To: edward.ing@utoronto.ca (Edward Ing) Cc: questions@FreeBSD.org Subject: Re: Static Link, Dynamic Link Libraryies, Shared Libraries, runtime libraries and which ones are which? Message-ID: <199611271608.RAA02569@freebie.lemis.de> In-Reply-To: <329B14EC.1A32@utoronto.ca> from Edward Ing at "Nov 26, 96 11:03:56 am"
next in thread | previous in thread | raw e-mail | index | archive | help
Edward Ing writes: > My understanding is that Shared libraries are symbolic linked > during compile by actuall get called during runtime. > > Thus to my ears shared libraries, runtime libraries and DLL > are really the same name for the same thing. Is this correct? Sort of. A runtime library can also be statically linked. See below. You're probably thinking of runtime binding, which isn't quite the same thing. And UNIX doesn't use the term DLL. > How can you distinguish between static libraries and shared libraries > on the FreeBSD library tree? A static library is a library which is used by the linker to build a statically linked executable. It's not needed at run time at all--you can delete it and the system will still run fine, but you won't be able to link any more programs which need that particular library. Static executables have the advantage that old programs will still run after a system upgrade. You can send them to other people running the same system, and they should work there too. In addition, they start up rather faster than dynamically linked executables, since the linking has already been done. They have the disadvantage that they can be much bigger than dynamically linked executables. A dynamic library is a library which is used by an executable at run time to resolve undefined symbols. The linker needs to know about it, but it doesn't need to have it present at the time it does the linking. The advantages and disadvantages of dynamically linked executables are the opposite of those of statically linked executables. In particular, you may need multiple versions of a specific library to cater for executables on your machine. By convention, static library names start with lib and end in .a (they're an 'ar' archive). Dynamic libraries end in .so followed by the version number. You'll also find profiling libraries (_p.a) and position independent libraries (_pic.a). For the C library, we thus have: libc.a is a static library. libc.so.2.0 is a dynamic library libc_p.a is a profiling static library libc_pic.a is a static library with position-independent code Remember, though, that these are just conventions. The only real way to tell what a file is for sure is to use the program 'file': > === grog@freebie (/dev/ttyp4) ~ 5 -> file /usr/lib/libc* > /usr/lib/libc.a: current ar archive random library > /usr/lib/libc.so.2.0: FreeBSD/i386 demand paged shared library not stripped > /usr/lib/libc.so.2.2: FreeBSD/i386 demand paged shared library not stripped > /usr/lib/libc.so.3.0: FreeBSD/i386 demand paged shared library not stripped > /usr/lib/libc_p.a: current ar archive random library > /usr/lib/libc_pic.a: current ar archive random library Greg
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199611271608.RAA02569>