GnuPG 1.4.0 vasprintf problem under WIN32

Joe Vender jvender at owensboro.net
Fri Dec 17 15:32:24 CET 2004


Attempts to "make" GnuPG 1.4.0 under MinGW/MSYS as per instructions by Carlo Luciano Bianco at http://clbianco.altervista.org/gnupg/eng/gnupg.html (alternative compilation instructions as modified slightly from 1.2.6 instructions) fail and return the following error:
****

if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I../intl    -O0 -mtune=i386 -march=i386 -mfpmath=387 -mno-mmx -mno-sse -mno-3dnow -mno-sse2 -Wall -MT bftest.o -MD -MP -MF ".deps/bftest.Tpo" -c -o bftest.o bftest.c; \
then mv -f ".deps/bftest.Tpo" ".deps/bftest.Po"; else rm -f ".deps/bftest.Tpo"; exit 1; fi
gcc  -O0 -mtune=i386 -march=i386 -mfpmath=387 -mno-mmx -mno-sse -mno-3dnow -mno-sse2 -Wall   -o bftest.exe  bftest.o ../cipher/libcipher.a ../mpi/libmpi.a ../util/libutil.a  -liconv -lintl  -lwsock32
../util/libutil.a(ttyio.o)(.text+0x1c3):ttyio.c: undefined reference to `vasprintf'
../util/libutil.a(ttyio.o)(.text+0x2b2):ttyio.c: undefined reference to `vasprintf'
collect2: ld returned 1 exit status
make[2]: *** [bftest.exe] Error 1
make[2]: Leaving directory `/home/default/gnupg-1.4.0/tools'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/default/gnupg-1.4.0'
make: *** [all] Error 2
****

I'm not a programmer, but playing around, here's what I've tried. In strgutil.c, if I modify the source with the following:
****


--- strgutil.c~	Wed Nov 17 09:50:58 2004
+++ strgutil.c	Fri Dec 17 08:00:16 2004
@@ -1161,6 +1161,11 @@
  * found in gcc-2.95.2 and a little bit modernized.
  * FIXME: Write a new CRT for W32.
  */
+
+#ifdef vasprintf
+  #undef vasprintf
+#endif
+
 int
 vasprintf (char **result, const char *format, va_list args)
 {



Then make succeeds. Make also succeeds if, using an unmodified strgutil.c, references to vasprintf are changed to libintl_vasprintf in ttyio.c:

--- ttyio.c~	Wed Nov 17 09:50:58 2004
+++ ttyio.c	Fri Dec 17 08:06:38 2004
@@ -208,9 +208,9 @@
         int n;
 	DWORD nwritten;

-	n = vasprintf(&buf, fmt, arg_ptr);
+	n = libintl_vasprintf(&buf, fmt, arg_ptr);
 	if( !buf )
-	    log_bug("vasprintf() failed\n");
+	    log_bug("libintl_vasprintf() failed\n");

 	if (!WriteConsoleA (con.out, buf, n, &nwritten, NULL))
 	    log_fatal ("WriteConsole failed: %s", w32_strerror (0));
@@ -255,9 +255,9 @@
         int n;
 	DWORD nwritten;

-	n = vasprintf(&buf, fmt, arg_ptr);
+	n = libintl_vasprintf(&buf, fmt, arg_ptr);
 	if( !buf )
-	    log_bug("vasprintf() failed\n");
+	    log_bug("libintl_vasprintf() failed\n");

 	if (!WriteConsoleA (con.out, buf, n, &nwritten, NULL))
 	    log_fatal ("WriteConsole failed: %s", w32_strerror (0));


I have no idea if either one of these is correct. I've found that vasprintf if defined extern in libintl.h, which is #included in i18n.h under WIN32 which is itself #included in bftest.c where this problem seems to occur.

The code references to vasprintf in libintl.h are:

#undef asprintf
#define asprintf libintl_asprintf
extern int asprintf (char **, const char *, ...);
#undef vasprintf
#define vasprintf libintl_vasprintf
extern int vasprintf (char **, const char *, va_list);


If anyone has any idea what's going on with this failure due to the vasprintf code when building under MinGW/MSYS as per instructions by Carlo Luciano Bianco at http://clbianco.altervista.org/gnupg/eng/gnupg.html , please post a solution.

Thanks.
Joe Vender





More information about the Gnupg-devel mailing list