This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Undefined reference to cygwin32_inet_aton in b18.


I have a small program which needs to use the inet_aton function.
When compiled with gcc under b18 (the code includes the
arpa/inet.h header), I get the message:

  undefined reference to 'cygwin32_inet_aton'
  gcc: Internal compiler error: program ld got fatal signal 1

I use the opposite function in my code (inet_ntoa) with no
difficulties.  Am I missing something here?  Or is the header
file incorrect (or the libraries missing a function)? I have attached a
short test program which exhibits the problem.

Any help would be appreciated,

Kelly Johnson
/*********************************************************************/
/*                                                                   */
/*  This routine retrieves the document associated with the URL      */
/*  specified as the first parameter.                                */
/*                                                                   */
/*  Written under contract by:                                       */
/*    J. Kelly Johnson                                               */
/*    Large Systems Specialists                                      */
/*                                                                   */
/*********************************************************************/

/*********************************************************************/
/*                                                                   */
/*  Defines/includes.                                                */
/*                                                                   */
/*********************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>  /* Socket fns (bind, connect, etc.)         */

#include <netinet/in.h>  /* Addr defs and net order fns (htons, etc.)*/
#include <arpa/inet.h>   /* Inet addr fns (inet_aton, inet_ntoa)     */
#include <netdb.h>       /* Network database fns (gethostbyname)     */

#include <sys/errno.h>

#define MAX_LINE 10000
#define MAX_WAIT 360       /* Max wait for server response (seconds).*/

/*********************************************************************/
/*                                                                   */
/*  Structures.                                                      */
/*                                                                   */
/*********************************************************************/
struct list_entry {                /* Event tree node structure.     */
  struct list_entry *left;
  struct list_entry *right;
  void *data;
  char key[1];
};
typedef struct list_entry list_node;

/*********************************************************************/
/*                                                                   */
/*  Function prototypes.                                             */
/*                                                                   */
/*********************************************************************/
static int error(int return_code, char *error_message);
FILE *get_response_stream(char *header, FILE *request_stream,
    struct sockaddr_in *server_socket_addr, int *rc_parm,
    char **msg_parm);
FILE *get_response_stream_error(int return_code, char *error_message,
    int *rc_parm, char **msg_parm);

/*********************************************************************/
/*                                                                   */
/*  Exported routine.                                                */
/*                                                                   */
/*********************************************************************/
main(int argc, char **argv)
{
  char message[1000];              /* Message buffer.                */

  char *program_name;              /* Executable name of this prog.  */
  char *server_name_parm;          /* Serv name specified (or NULL). */
  struct in_addr ip_addr;          /* Network form of IP address.    */
  struct hostent *server_host_entry;/* Info from gethostbyname.      */
  int server_port;                 /* Target port on server.         */
  char *source_file_parm;          /* Source file name parameter.    */
  FILE *source_file_stream;        /* Source file stream.            */
  int parm_error;                  /* Flag indicating parm error.    */

  struct in_addr *server_in_addr;  /* Server internet address.       */
  struct sockaddr_in server_socket_addr;  /* Server socket address.  */

  FILE *response_stream;           /* Server response stream.        */
  int return_code;                 /* Result code from function call.*/
  char *error_message;             /* Error message from fn call.    */

  char buffer[20000];              /* Read/write buffer.             */
  int bytes_written;               /* No. of bytes written to socket.*/
  int bytes_read;                  /* No. of bytes read from socket. */

  /*******************************************************************/
  /*                                                                 */
  /*  Validate the parameters.                                       */
  /*                                                                 */
  /*******************************************************************/
  program_name = *argv;
  server_name_parm = NULL;
  server_port = 80;
  parm_error = 0;

  while (!parm_error && *++argv) {
    if (!strcmp(*argv, "-s")) {
      /***************************************************************/
      /*                                                             */
      /*  Found a web server name specifier.                         */
      /*                                                             */
      /***************************************************************/
      if (!(server_name_parm = *++argv))
        parm_error = 1;
      else if (inet_aton(server_name_parm, &ip_addr) &&
          (server_host_entry = gethostbyaddr((char *) &ip_addr,
          sizeof(struct in_addr), AF_INET)));
      else if (!(server_host_entry = gethostbyname(server_name_parm))) {
        sprintf(message, "Cannot resolve server name \"%s\".",
            server_name_parm);
        return error(4, message);
      }
    }
    else if (**argv == '-')
      /***************************************************************/
      /*                                                             */
      /*  Found an unknown option.                                   */
      /*                                                             */
      /***************************************************************/
      parm_error = 1;

    else if (source_file_parm)
      /***************************************************************/
      /*                                                             */
      /*  Found an extraneous parameter.                             */
      /*                                                             */
      /***************************************************************/
      parm_error = 1;

    else {
      /***************************************************************/
      /*                                                             */
      /*  Found the source file to send.                             */
      /*                                                             */
      /***************************************************************/
      source_file_parm = *argv;
      if (!(source_file_stream = fopen(source_file_parm, "r"))) {
        sprintf(message, "Error opening source file \"%s\".",
            source_file_parm);
        return error(8, message);
      }
    }
  }

  if (parm_error || !source_file_parm) {
    sprintf(message, "\nUsage:      %s [-s target_server] source_file\n\n"
        "Author:     J. Kelly Johnson, (408) 223-1327\n"
        "Copyright:  LSS 1996 - all rights reserved.", program_name);
    return error(16, message);
  }

  return 0;
}

/*********************************************************************/
/*                                                                   */
/*  Error routine.  Output passed error message and return the       */
/*  specified return code as a result.                               */
/*                                                                   */
/*********************************************************************/
static int error(int return_code, char *error_message)
{
  fprintf(stderr, "%s\n", error_message);
  return return_code;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]