home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / programm / 4321 < prev    next >
Encoding:
Internet Message Format  |  1992-08-15  |  1.7 KB

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