Solved

gethostbyname

Posted on 1998-04-07
5
646 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
Comment Utility
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
Comment Utility
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
Comment Utility
It doesn't appear that andrewyu has ever graded any answer.
0
 
LVL 2

Expert Comment

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

Expert Comment

by:Johannne1
Comment Utility
I got the above solution but I also had to add lsocket.

gcc -lsocket -lnsl myprogram.c
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
windows 10 how make picture as desktop background 2 47
sumNumber challenge 16 98
sumHeights2  challenge 7 75
noX challenge 17 75
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

14 Experts available now in Live!

Get 1:1 Help Now