Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
* gcc and gethostbyname: where is the library
@ 2002-07-02 13:38 alex
  2002-07-02 14:49 ` Paul Pluzhnikov
  2002-07-03  7:48 ` alex
  0 siblings, 2 replies; 5+ messages in thread
From: alex @ 2002-07-02 13:38 UTC (permalink / raw)


Hello,

I cannot figure out why gcc cannot link the following file:
>cat a.cpp
#include <netdb.h>
main()
{
   struct hostent* he;

   he = gethostbyname( "testje" );
}


>gcc a.cpp
/usr/bin/ld:
Unresolved:
gethostbyname(char const *)
collect2: ld returned 1 exit status

>gcc -v
Reading specs from /usr/local/lib/gcc-lib/alphaev6-dec-osf5.1/2.95.3/specs
gcc version 2.95.3 20010315 (release)

I've also installed gcc 3.0.4, of course without any success.

Can anyone help me
It would be **greatly** appreciated

Alex


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc and gethostbyname: where is the library
  2002-07-02 13:38 gcc and gethostbyname: where is the library alex
@ 2002-07-02 14:49 ` Paul Pluzhnikov
  2002-07-02 17:09   ` Atlant Schmidt
  2002-07-03  7:48 ` alex
  1 sibling, 1 reply; 5+ messages in thread
From: Paul Pluzhnikov @ 2002-07-02 14:49 UTC (permalink / raw)


alex <alexandre.masselot@bigfoot.com> writes:

> I cannot figure out why gcc cannot link the following file:
> >cat a.cpp
...
> /usr/bin/ld:
> Unresolved:
> gethostbyname(char const *)

What this means is that 'gethostbyname' has aquired C++ linkage,
and the linker is now looking for gethostbyname__FPCc (which
is not there).

So it is a compilation problem. However I can not reproduce this
using gcc-2.95.3 on a 5.0 system.

Perhaps if you add 'extern "C" struct hostent *gethostbyname(const char *);'
somewhere after 'netdb.h' gcc will either stop C++mangling or tell you
where "bad" gethostbyname prototype is coming from.

Cheers,
-- 
In order to understand recursion you must first understand recursion.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc and gethostbyname: where is the library
  2002-07-02 14:49 ` Paul Pluzhnikov
@ 2002-07-02 17:09   ` Atlant Schmidt
  2002-07-03  5:05     ` Paul Pluzhnikov
  0 siblings, 1 reply; 5+ messages in thread
From: Atlant Schmidt @ 2002-07-02 17:09 UTC (permalink / raw)


Paul Pluzhnikov wrote:

> alex <alexandre.masselot@bigfoot.com> writes:
>
> > I cannot figure out why gcc cannot link the following file:
> > >cat a.cpp
> ...
> > /usr/bin/ld:
> > Unresolved:
> > gethostbyname(char const *)
>
> What this means is that 'gethostbyname' has aquired C++ linkage,
> and the linker is now looking for gethostbyname__FPCc (which
> is not there).

I mustn't understand the question/answer [:-)] because I
would have suggested:

  % gcc a.cpp -lnsl

so that libnsl gets linked in. At least on Solaris, that's
where gethostbyname() lives.

Atlant




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc and gethostbyname: where is the library
  2002-07-02 17:09   ` Atlant Schmidt
@ 2002-07-03  5:05     ` Paul Pluzhnikov
  0 siblings, 0 replies; 5+ messages in thread
From: Paul Pluzhnikov @ 2002-07-03  5:05 UTC (permalink / raw)


Atlant Schmidt <atlantnospam@mindspring.com> writes:

> Paul Pluzhnikov wrote:
> 
> > alex <alexandre.masselot@bigfoot.com> writes:
> >
> > > I cannot figure out why gcc cannot link the following file:
> > > >cat a.cpp
> > ...
> > > /usr/bin/ld:
> > > Unresolved:
> > > gethostbyname(char const *)
> >
> > What this means is that 'gethostbyname' has aquired C++ linkage,
> > and the linker is now looking for gethostbyname__FPCc (which
> > is not there).
> 
> I mustn't understand the question/answer [:-)] because I
> would have suggested:
> 
>   % gcc a.cpp -lnsl
> 
> so that libnsl gets linked in. At least on Solaris, that's
> where gethostbyname() lives.

But the question was about Tru64, where:

  $ nm /shlib/libc.so | grep gethostbyname
    __gethostbyname                  | 0004395899947296 | T | 0000000000000008
    __gethostbyname_local            | 0004395900375248 | T | 0000000000000008
    __gethostbyname_r                | 0004395900385184 | T | 0000000000000008
    gethostbyname                    | 0004395899947296 | T | 0000000000000008
    gethostbyname_local              | 0004395900375248 | T | 0000000000000008
    gethostbyname_r                  | 0004395900385184 | T | 0000000000000008

and libnsl.{a,so} does not exist (at least not in any of the default
directories).

Cheers,
-- 
In order to understand recursion you must first understand recursion.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc and gethostbyname: where is the library
  2002-07-02 13:38 gcc and gethostbyname: where is the library alex
  2002-07-02 14:49 ` Paul Pluzhnikov
@ 2002-07-03  7:48 ` alex
  1 sibling, 0 replies; 5+ messages in thread
From: alex @ 2002-07-03  7:48 UTC (permalink / raw)


Hi there,

thanks for your help.

With your tip, I could get into the observation that we have 2 netdb.h
files (a dummy one in /usr/local/include and a good one into
/usr/include)
g++ was selecting the bad one by default.



Tahnks for your help
Alex

On Tue, 02 Jul 2002 15:38:44 +0200, alex wrote:

> Hello,
> 
> I cannot figure out why gcc cannot link the following file:
>>cat a.cpp
> #include <netdb.h>
> main()
> {
>    struct hostent* he;
> 
>    he = gethostbyname( "testje" );
> }
> 
> 
>>gcc a.cpp
> /usr/bin/ld:
> Unresolved:
> gethostbyname(char const *)
> collect2: ld returned 1 exit status
> 
>>gcc -v
> Reading specs from
> /usr/local/lib/gcc-lib/alphaev6-dec-osf5.1/2.95.3/specs gcc version
> 2.95.3 20010315 (release)
> 
> I've also installed gcc 3.0.4, of course without any success.
> 
> Can anyone help me
> It would be **greatly** appreciated
> 
> Alex


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-07-03  7:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-02 13:38 gcc and gethostbyname: where is the library alex
2002-07-02 14:49 ` Paul Pluzhnikov
2002-07-02 17:09   ` Atlant Schmidt
2002-07-03  5:05     ` Paul Pluzhnikov
2002-07-03  7:48 ` alex

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox