home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / next / programm / 7881 < prev    next >
Encoding:
Text File  |  1992-12-22  |  2.2 KB  |  74 lines

  1. Newsgroups: comp.sys.next.programmer
  2. Path: sparky!uunet!gatech!concert!uvaarpa!murdoch!cds001!quarrie
  3. From: quarrie@cds001.cebaf.gov (David Quarrie)
  4. Subject: Unresolved references when linking
  5. Message-ID: <1992Dec22.173036.7075@murdoch.acc.Virginia.EDU>
  6. Sender: usenet@murdoch.acc.Virginia.EDU
  7. Reply-To: quarrie@cds001.cebaf.gov (David Quarrie)
  8. Organization: CEBAF (Continuous Electron Beam Accelerator Facility)
  9. Date: Tue, 22 Dec 1992 17:30:36 GMT
  10. Lines: 62
  11.  
  12. --
  13. The following is relevant to NeXTSTEP3.0.
  14.  
  15. I'm experiencing problems with unresolved references when using archives (.a).
  16. This isn't just my own .a files, but also libX11.a for X-Windows. As far as
  17. I can ascertain, it's a problem with global symbols instead of global routines
  18. and can be illustrated by the following (I haven't actually done the following
  19. since I'm not in front of my NeXT but I think it should illustrate the
  20. problem):
  21.  
  22.   (a)    Create a file file1.c containing the following:
  23.  
  24.         int global;
  25.  
  26.   (b)    Create a file file2.c containing the following:
  27.  
  28.         extern int global;
  29.     
  30.         int hello()
  31.         {
  32.                 return (global);
  33.         }
  34.  
  35.   (c)    Create a file file3.c containing:
  36.  
  37.         main ()
  38.         {
  39.                 hello();
  40.         }
  41.  
  42.    (d)    Compile the files:
  43.  
  44.         cc -c file1.c file2.c file3.c
  45.  
  46.    (e)    Create an archive from file1.o and file2.o
  47.  
  48.         ar -r files.a file1.o file2.o
  49.         ranlib files.a
  50.  
  51.    (f)    Link the application:
  52.  
  53.         cc -o myapp file3.o files.a
  54.  
  55. and with a bit of luck you should get the unresolved reference _global. If you
  56. don't then I've oversimplified the problem and will have to go back to the
  57. drawing board (i.e. my NeXT) to put a better example together.
  58.  
  59. Am I doing something stupid? Is it a case of RTFM? So far I've managed to force
  60. linking to succeed by extracting the appropriate .o files from the library
  61. and explicitly linking them, but I wouldn't have thought I should need to do 
  62. that. 
  63.  
  64. Any (constructive) comments and suggestions gratefully received.
  65.  
  66.         David
  67.  
  68. -------------------------------------------------------------------------------
  69.     David Quarrie                    CEBAF MS 12H
  70.                             12000 Jefferson Ave
  71. Internet: quarrie@cebaf.gov                Newport News VA 23606
  72. DECnet  : cebaf::quarrie                Tel: (804) 249-7562
  73. BITNET  : quarrie@cebaf                    Fax: (804) 249-5800
  74.