Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Where is the library for gethostbyname() ?

591 views
Skip to first unread message

csteow

unread,
Sep 26, 2001, 6:39:23 AM9/26/01
to
Hi:

I try to compile a program which uses gethostbyname() using GCC, the
compiler complaint can not like to gethostbyname.

I already try to link using -lsocket, but it does not help? Where is the
gethostbyname() library store?

Regards,
Chin Siang


Dimitri Maziuk

unread,
Sep 26, 2001, 3:14:05 PM9/26/01
to

*sigh* Which OS is that? If it's Solaris, which part of

Network Functions gethostbyname(3N)


NAME
gethostbyname, gethostbyname_r, gethostbyaddr,
gethostbyaddr_r, gethostent, gethostent_r, sethostent,
endhostent - get network host entry

SYNOPSIS
cc [ flag ... ] file ... -lnsl [ library ... ]
#include <netdb.h>

do you not understand?

Dima
--
Well, lusers are technically human. -- Red Drag Diva

csteow

unread,
Sep 26, 2001, 9:21:20 PM9/26/01
to
Hi:

I got compilation error on Sun Solaris 5.7 using GCC 2.95 using -lsocket -lm
option

Undefined first referenced
symbol in file
dlclose /usr/lib/libp/libc.a(nss_deffinder.o)
(symb
ol belongs to implicit dependency /usr/lib/libdl.so.1)
gethostbyname BaseSocket.o (symbol belongs to
implicit de
pendency /usr/lib/libnsl.so.1)
inet_addr BaseSocket.o (symbol belongs to
implicit de
pendency /usr/lib/libnsl.so.1)
inet_ntoa BaseServer.o (symbol belongs to
implicit de
pendency /usr/lib/libnsl.so.1)
dlsym /usr/lib/libp/libc.a(nss_deffinder.o)
(symb
ol belongs to implicit dependency /usr/lib/libdl.so.1)
dlopen /usr/lib/libp/libc.a(nss_deffinder.o)
(symb
ol belongs to implicit dependency /usr/lib/libdl.so.1)
ld: fatal: Symbol referencing errors. No output written to mmds
collect2: ld returned 1 exit status

What library am I missing?

Regards,
Chin Siang

"Dimitri Maziuk" <di...@127.0.0.1> wrote in message
news:slrn9r4a7...@odyssey.bmrb.wisc.edu...

csteow

unread,
Sep 26, 2001, 10:19:36 PM9/26/01
to
Thanks Dima.

I should link using -lnsl

Regards,
Chin Siang

"Dimitri Maziuk" <di...@127.0.0.1> wrote in message
news:slrn9r4a7...@odyssey.bmrb.wisc.edu...

Götz Babin-Ebell

unread,
Sep 27, 2001, 6:17:44 AM9/27/01
to
csteow wrote:
> Hi:
Hello,

> I got compilation error on Sun Solaris 5.7 using GCC 2.95 using -lsocket -lm
> option

*sigh*

It's no compilation error.
It is a link error.

I don't want to be offensive,
but if you want to build programs,
you have to learn to resolve such problems yourself.

And the first
authority you have to ask are the man pages.

try a
man dlclose
to get the library you have to link...

If your man pages don't have these information
(the linux man pages have this bug)
try a nm -g <library file> | grep <function name>
until you have found the symbol.

To exercise this try a

man dlclose
man gethostbyname
man dlsym
man dlopen


Bye

Goetz

--
Goetz Babin-Ebell, TC TrustCenter AG, http://www.trustcenter.de
Sonninstr. 24-28, 20097 Hamburg, Germany
Tel.: +49-(0)40 80 80 26 -0, Fax: +49-(0)40 80 80 26 -126

0 new messages