?
Solved

gethostbyname

Posted on 1998-04-07
5
Medium Priority
?
719 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month8 days, 17 hours left to enroll

765 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