🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
3 messages
3 total messages Started by David Quarrie Tue, 22 Dec 1992 17:30
Unresolved references when linking
#1937
Author: 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
Re: Unresolved references when linking
#1943
Author: Louis A. Mamakos
Date: Wed, 23 Dec 1992 01:22
25 lines
1493 bytes
In article <1992Dec22.173036.7075@murdoch.acc.Virginia.EDU> quarrie@cds001.cebaf.gov (David Quarrie) writes:
>--
>The following is relevant to NeXTSTEP3.0.

And, actually NeXTSTEP 2.x and earlier, too.

>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):

[...example omitted...]

>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. 

Stupid?  Well, I don't think so.  Yes, RTFM, specifically 'man
ranlib'.  I think the -c option will do what you need.


louie
Re: Unresolved references when linking
#1950
Author: David Quarrie
Date: Wed, 23 Dec 1992 13:36
54 lines
2540 bytes
--
In article <1h8f0hINNota@ni.umd.edu>, louie@sayshell.umd.edu (Louis A.
Mamakos) writes:
|>
|>In article <1992Dec22.173036.7075@murdoch.acc.Virginia.EDU>
|>quarrie@cds001.cebaf.gov (David Quarrie) writes:
|>>--
|>>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):
|>
|>[...example omitted...]
|>
|>>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. 
|>
|>Stupid?  Well, I don't think so.  Yes, RTFM, specifically 'man
|>ranlib'.  I think the -c option will do what you need.
|>
|>
|>louie
|>

Louie is, of course, absolutely correct. ranlib -c works just fine and does the
job. There are times when I just HATE U**x and the fact that they all appear
to be identical, but they're all just a little bit different. I think it's
worse than using VAX/VMS and U**x, at least you know they're going to be
different.

I'm also intrigued by the fact that the libX11.a supplied by Cub'X also needs
this to be done. Is this a well known fact or am I the first person to try
building an X application? -)

Thanks again to Louie...

-------------------------------------------------------------------------------
	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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads