delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/10/31/03:33:33

Date: Sun, 31 Oct 1999 09:42:30 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: djgpp-workers AT delorie DOT com
Subject: gxx complains about missing -lgpp
Message-ID: <Pine.SUN.3.91.991031094139.2988J-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

Somebody complained on c.o.m.d. that gxx causes an error message if
libgpp.a isn't installed.  Since libgpp is deprecated and people need
not download it (the FAQ even recommends so), I think we should fix
this.  So how about the following change to gxx.c?

*** src/utils/gxx.c~0	Thu Jun  3 20:27:42 1999
--- src/utils/gxx.c	Sun Oct 31 00:19:58 1999
***************
*** 1,14 ****
--- 1,43 ----
+ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
  #include <stdio.h>
  #include <process.h>
  #include <stdlib.h>
+ #include <unistd.h>
  
  char lgpp[] = "-lgpp";
  char lstdc[] = "-lstdcxx";
  char lm[] = "-lm";
  
+ static int
+ libgpp_installed (void)
+ {
+   FILE *fp = popen("gcc.exe -print-file-name=libgpp.a", "r");
+   char libgpp_name[FILENAME_MAX];
+   int retval = 0;
+ 
+   if (fp)
+   {
+     int fnlen = fread(libgpp_name, 1, FILENAME_MAX - 1, fp);
+ 
+     if (fnlen != -1 && fnlen <= FILENAME_MAX - 1)
+     {
+       if (libgpp_name[fnlen-1] == '\n')
+         fnlen--;
+       libgpp_name[fnlen] = '\0';
+       if (__file_exists(libgpp_name))
+         retval = 1;
+     }
+     pclose(fp);
+   }
+   else
+     perror("gxx: gcc.exe");
+ 
+   return retval;
+ }
+ 
  int
  main(int argc, char **argv)
  {
*************** main(int argc, char **argv)
*** 26,32 ****
  
    if (add_libs) {
      newargs[i++] = lstdc;
!     newargs[i++] = lgpp;
      newargs[i++] = lm;
    }
    newargs[i++] = 0;
--- 55,62 ----
  
    if (add_libs) {
      newargs[i++] = lstdc;
!     if (libgpp_installed())
!       newargs[i++] = lgpp;
      newargs[i++] = lm;
    }
    newargs[i++] = 0;

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019