Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com> List-Archive: <http://sourceware.cygnus.com/ml/cygwin/> List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com> List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs> Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-ID: <F1BF31E0C22AD2118B3B00805FCA4F95153FC0@MAIL1> From: Olivier Jacquemin <Olivier DOT Jacquemin AT DialogSystems DOT be> To: "'cygwin AT sourceware DOT cygnus DOT com'" <cygwin AT sourceware DOT cygnus DOT com> Subject: sockets: problem using h_errno Date: Mon, 22 May 2000 11:39:47 +0200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain Hello, I'm trying to compile a C program that was created on Unix. It uses sockets: one of the source files includes the netdb.h file and uses h_errno to get the error code after a call to getHostByName(). See the code below. #include <netdb.h> /* getservbyname(), gethostbyname(),HOST_NOT_FOUND */ /* CODE SKIPPED */ int tcp_open(){ struct sockaddr_in server; struct servent* servp; struct hostent* servh; assert(myFd >= 0); /* get the host address from /etc/hosts */ if ((servh=gethostbyname(Machine_name)) == NULL){ if (h_errno == HOST_NOT_FOUND){ /* CODE SKIPPED */ At compile time, ld complains about an "undefined reference to h_errno" from the last line above. In netdb.h, here is the definition of h_errno (I don't use the -D__INSIDE_CYGWIN_NET__ flag in gcc): #ifdef __INSIDE_CYGWIN_NET__ extern int h_errno; #else extern __declspec(dllimport) int h_errno; #endif At the end of the compilation process, I link the object files against the cygwin library: gcc -Wall -ansi -D__STDC__=0 MsgHandler.o SCPLoadLog.o timeval.o TcpGate.o SCPLoadSim.o -o SCPLoadSim -lcygwin I thought this library exports h_errno... Do you have an idea ? I know this could be a very basic question on how to use gcc... sorry if it is so. Many thanks, _Olivier_ -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com