Solved

gethostbyname

Posted on 1998-04-07
5
658 Views
Last Modified: 2013-12-26
UNIXer,

If I need to use gethostbyname in my program which is compile by gcc in SunSpace !
But I get ths following error message, so, what caI do ?

-------------------------------------------------------------------------
Undefined                       first referenced
 symbol                             in file
gethostbyname                       /var/tmp/cca000t71.o
ld: fatal: Symbol referencing errors. No output written to a.out
---------------------------------------------------------------------------------

Andrew
0
Comment
Question by:andrewyu
  • 3
5 Comments
 
LVL 2

Accepted Solution

by:
seedy earned 0 total points
ID: 1296238
Man page for 'gethostbyname' states:
   cc  [ flag ... ] file ... -lnsl [ library ...]

You need to link the 'nsl' library!
Cheers,
-Seedy-

0
 
LVL 2

Expert Comment

by:seedy
ID: 1296239
Andrewyu,

Please let me know why you rated this answer or the previous
one - 'DNS' under Unix Programming as 'C'?
Would you have liked anything else too?

you answering this would help me help others better.
Cheers.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1296240
It doesn't appear that andrewyu has ever graded any answer.
0
 
LVL 2

Expert Comment

by:seedy
ID: 1296241
Oops!  Was this auto-graded?  How can I find the difference?
0
 

Expert Comment

by:Johannne1
ID: 24989403
I got the above solution but I also had to add lsocket.

gcc -lsocket -lnsl myprogram.c
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now