🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #52602

Re: gcc 2.2.2 linking problem: gethostbyname

#52602
From: Casper H.S. Dik
Date: Fri, 26 Jun 1992 18:02
40 lines
1824 bytes
warkent@ltisun9.epfl.ch (Ken Warkentyne) writes:

>Here is a small program that is supposed to find out if the machine on which it
>is executing is the "localhost".

>----file bob.c----
>#include <netdb.h>
>main()
>{
>    int not_local;
>    char localname[255];
>    struct hostent *hst = gethostbyname ("localhost");
>    not_local = !hst || !!(strcmp (localname, hst->h_name));
>    printf("%d\n",not_local);
>}
>----eof----

>When I try to compile this by typing "gcc bob.c", I get the following error messages:

>    gethostnamadr.o: undefined reference to `__GLOBAL_OFFSET_TABLE_'
>    ...
>    gethostnamadr.o: more undefined references to `__GLOBAL_OFFSET_TABLE_' follow

>The ld program is the GNU version from binutils-beta-1.94.

Your problem is two fold:

	- someone has put libresolv.a in libc.a, probably because
	  he put the resolver in libc.so.* too.
	- The resolver library is compiled with -pic, so that
	  sun users can put it in libc.so.*.

GNU ld doesn't understand objectfiles compiled with -pic.
The gcc installation should use collect and the native
linker, rather than GNU ld.

Casper
-- 
						|	Casper H.S. Dik
						|	casper@fwi.uva.nl
Technical Details
Message-ID: <1992Jun26.180228.13566@fwi.uva.nl>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!fwi.uva.nl!casper
References: <WARKENT.92Jun26171407@ltisun9.epfl.ch>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,b6bc61d46913c24f
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1992-06-26 06:09:16 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!fwi.uva.nl!casper
From: casper@fwi.uva.nl (Casper H.S. Dik)
Subject: Re: gcc 2.2.2 linking problem: gethostbyname
Message-ID: <1992Jun26.180228.13566@fwi.uva.nl>
Sender: news@fwi.uva.nl
Nntp-Posting-Host: adam.fwi.uva.nl
Organization: FWI, University of Amsterdam
References: <WARKENT.92Jun26171407@ltisun9.epfl.ch>
Distribution: gnu
Date: Fri, 26 Jun 1992 18:02:28 GMT
Lines: 40