🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.programmer
Article #1937

Unresolved references when linking

#1937
From: David Quarrie
Date: Tue, 22 Dec 1992 17:30
62 lines
2295 bytes
--
The following is relevant to NeXTSTEP3.0.

I'm experiencing problems with unresolved references when using archives (.a).
This isn't just my own .a files, but also libX11.a for X-Windows. As far as
I can ascertain, it's a problem with global symbols instead of global routines
and can be illustrated by the following (I haven't actually done the following
since I'm not in front of my NeXT but I think it should illustrate the
problem):

  (a)	Create a file file1.c containing the following:

		int global;

  (b)	Create a file file2.c containing the following:

		extern int global;
	
		int hello()
		{
		        return (global);
		}

  (c)	Create a file file3.c containing:

		main ()
		{
	 	       hello();
		}

   (d)	Compile the files:

		cc -c file1.c file2.c file3.c

   (e)	Create an archive from file1.o and file2.o

		ar -r files.a file1.o file2.o
		ranlib files.a

   (f)	Link the application:

		cc -o myapp file3.o files.a

and with a bit of luck you should get the unresolved reference _global. If you
don't then I've oversimplified the problem and will have to go back to the
drawing board (i.e. my NeXT) to put a better example together.

Am I doing something stupid? Is it a case of RTFM? So far I've managed to force
linking to succeed by extracting the appropriate .o files from the library
and explicitly linking them, but I wouldn't have thought I should need to do 
that. 

Any (constructive) comments and suggestions gratefully received.

		David

-------------------------------------------------------------------------------
	David Quarrie					CEBAF MS 12H
							12000 Jefferson Ave
Internet: quarrie@cebaf.gov				Newport News VA 23606
DECnet  : cebaf::quarrie				Tel: (804) 249-7562
BITNET  : quarrie@cebaf					Fax: (804) 249-5800
Technical Details
Message-ID: <1992Dec22.173036.7075@murdoch.acc.Virginia.EDU>
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!concert!uvaarpa!murdoch!cds001!quarrie

Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!concert!uvaarpa!murdoch!cds001!quarrie
From: quarrie@cds001.cebaf.gov (David Quarrie)
Subject: Unresolved references when linking
Message-ID: <1992Dec22.173036.7075@murdoch.acc.Virginia.EDU>
Sender: usenet@murdoch.acc.Virginia.EDU
Reply-To: quarrie@cds001.cebaf.gov (David Quarrie)
Organization: CEBAF (Continuous Electron Beam Accelerator Facility)
Date: Tue, 22 Dec 1992 17:30:36 GMT
Lines: 62