home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!auspex-gw!guy
- From: guy@Auspex.COM (Guy Harris)
- Newsgroups: comp.unix.programmer
- Subject: Re: How to create a shared object library (lib??.so.??)
- Message-ID: <14076@auspex-gw.auspex.com>
- Date: 15 Aug 92 17:31:48 GMT
- References: <1992Aug15.023631.2697@pasteur.Berkeley.EDU>
- Sender: news@auspex-gw.auspex.com
- Distribution: usa
- Organization: Auspex Systems, Santa Clara
- Lines: 25
- Nntp-Posting-Host: auspex.auspex.com
-
- > To create a static object library, one uses "cc -c ..." and
- >"ar rcv lib.... *.o". But how does one create a shared object
- >library. I tried using the same steps and then set LD_LIBRARY_PATH
- >but system complains about lib??.so.?? being in incorrect format.
-
- Yup. Shared and non-shared libraries are different types of files.
-
- To create a shared object file, one should use "cc -c -pic ..." and
- "ld -o lib.so.Maj.Min *.o".
-
- "-pic", in the "cc" line, causes "position-independent code" to be
- generated. That means that the library doesn't have to be relocated
- when it's attached to the process, which is a Good Thing.
-
- "Maj" and "Min", in the "ld" command line, are the major and minor
- numbers you want for your shared library. When you first create it, you
- probably want a major version number of 1, and a minor version number of
- 0. If you change the library so that programs linked with the old
- version should work with the new version, but programs linked with the
- new version may not work with the old version (for example, if you add a
- new routine, or a new option to an old routine), bump the minor version
- number; if you change the library such that programs linked with the old
- version won't necessarily work with the new version (for example, if you
- incompatibly change the calling sequence to a routine), bump the major
- version number.
-