Complete.Org: Mailing Lists: Archives: freeciv-dev: November 1998:
Re: [Freeciv-Dev] Linker error?
Home

Re: [Freeciv-Dev] Linker error?

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: athompso@xxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: Re: [Freeciv-Dev] Linker error?
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Tue, 3 Nov 1998 21:27:37 +1100

Drew Thompson wrote:
> 
> All,
>    I'm trying to compile FreeCiv on a SparcStation...I'm getting
> the following error:
> ld: Undefined symbol
>    _strerror
> collect2: ld returned 2 exit status
> 
> While running configure, I notice:
> 
> checking for strerror... no
> 
> 1) Am I out of luck?
> 2) Are these related, i.e. should configure be doing something
> differently since it knows there's no strerror?

My guess is that _we're_ supposed to be doing something differently,
such as the attached patch.  (But I'm making this up as I go along, 
so anyone feel free to correct me.)

(What your platform thinks its doing without strerror which I believe
is part of the ANSI C standard library I don't known, though I guess
it must be common enough for configure to check for it...)

-- David
diff -u -r --exclude-from exclude freeciv-cvs/client/clinet.c 
freeciv-mod/client/clinet.c
--- freeciv-cvs/client/clinet.c Mon Sep 21 19:19:25 1998
+++ freeciv-mod/client/clinet.c Tue Nov  3 21:09:26 1998
@@ -92,12 +92,12 @@
   signal (SIGPIPE, SIG_IGN);
   
   if((aconnection.sock = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
-    strcpy(errbuf, strerror(errno));
+    strcpy(errbuf, mystrerror(errno));
     return -1;
   }
   
   if(connect(aconnection.sock, (struct sockaddr *) &src, sizeof (src)) < 0) {
-    strcpy(errbuf, strerror(errno));
+    strcpy(errbuf, mystrerror(errno));
     close(aconnection.sock);
     return -1;
   }
@@ -189,12 +189,12 @@
   addr.sin_port = htons(80);
   
   if((s = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
-    strcpy(errbuf, strerror(errno));
+    strcpy(errbuf, mystrerror(errno));
     return -1;
   }
   
   if(connect(s, (struct sockaddr *) &addr, sizeof (addr)) < 0) {
-    strcpy(errbuf, strerror(errno));
+    strcpy(errbuf, mystrerror(errno));
     close(s);
     return -1;
   }
diff -u -r --exclude-from exclude freeciv-cvs/common/shared.c 
freeciv-mod/common/shared.c
--- freeciv-cvs/common/shared.c Thu Oct 29 20:22:12 1998
+++ freeciv-mod/common/shared.c Tue Nov  3 21:11:46 1998
@@ -253,6 +253,20 @@
    return mystrcasecmp(*((char **)first), *((char **)second));
 }
 
+/***************************************************************
+...
+***************************************************************/
+char *mystrerror(int errnum)
+{
+#ifdef HAVE_STRERROR
+  return strerror(errnum);
+#else
+  static char buf[64];
+  sprintf(buf, "error %d (compiled without strerror())", errnum);
+  return buf;
+#endif
+}
+
 
 /*************************************************************************
    The following random number generator can be found in _The Art of 
diff -u -r --exclude-from exclude freeciv-cvs/common/shared.h 
freeciv-mod/common/shared.h
--- freeciv-cvs/common/shared.h Thu Oct 29 20:22:12 1998
+++ freeciv-mod/common/shared.h Tue Nov  3 21:06:48 1998
@@ -84,6 +84,7 @@
 char *get_dot_separated_int(unsigned val);
 char *mystrdup(char *);
 int mystrcasecmp(char *str0, char *str1);
+char *mystrerror(int errnum);
 RANDOM_TYPE myrand(int size);
 void mysrand(RANDOM_TYPE seed);
 int string_ptr_compare(const void *first, const void *second);
diff -u -r --exclude-from exclude freeciv-cvs/server/sernet.c 
freeciv-mod/server/sernet.c
--- freeciv-cvs/server/sernet.c Mon Aug 24 09:27:15 1998
+++ freeciv-mod/server/sernet.c Tue Nov  3 21:11:17 1998
@@ -219,7 +219,7 @@
   signal (SIGPIPE, SIG_IGN);
   
   if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-    flog(LOG_FATAL, "socket failed: %s", strerror(errno));
+    flog(LOG_FATAL, "socket failed: %s", mystrerror(errno));
     exit(1);
   }
 
@@ -227,16 +227,16 @@
   if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, 
                (char*)&opt, sizeof(opt))) {
 /*             (const char*)&opt, sizeof(opt))) {      gave me warnings -- 
Syela */
-    flog(LOG_FATAL, "setsockopt failed: %s", strerror(errno));
+    flog(LOG_FATAL, "setsockopt failed: %s", mystrerror(errno));
   }
 
   if(bind(sock, (struct sockaddr *) &src, sizeof (src)) < 0) {
-    flog(LOG_FATAL, "bind failed: %s", strerror(errno));
+    flog(LOG_FATAL, "bind failed: %s", mystrerror(errno));
     exit(1);
   }
 
   if(listen(sock, MAX_CONNECTIONS) < 0) {
-    flog(LOG_FATAL, "listen failed: %s", strerror(errno));
+    flog(LOG_FATAL, "listen failed: %s", mystrerror(errno));
     exit(1);
   }
 

[Prev in Thread] Current Thread [Next in Thread]