bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gettext: compilation/link errors (DLL on MinGW/MSYS (Win32))


From: Mark Junker
Subject: Re: gettext: compilation/link errors (DLL on MinGW/MSYS (Win32))
Date: Wed, 08 Jun 2005 10:32:09 +0200
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

Bruno Haible schrieb:

1. Compilation for C# referencing "GNU.Gettext" doesn't work. On Win32
platforms, you must specify as "GNU.Gettext.dll" as library

The Makefile.am that's affected is gettext-tools/src/Makefile.am. The
compilation of msgunfmt.net.exe from msgunfmt.cs must use -l
GNU.Gettext.dll.
The .dll in the filename exists on all platforms, but apparently some
C# compilers add the .dll suffix and some don't. The script that shall
ensure portability across all C# compilers is
gettext-tools/lib/csharpcomp.sh.in. Can you modify it so that it works
with your C# compiler?

The C# compiler is csc from the Microsoft .NET framework. The attached patch (gettext_csharpcomp.sh.in.patch) should fix it. Anyway, I don't know if there are other C# compilers that are executed by calling "csc". When there are other "csc" C# compilers out there, this change might break their support.

2. On MinGW, the mbrtowc function can only be found in the libmsvcp60
library.

You have to add -lmsvcp60 on the MinGW/MSYS platform in
gettext-tools/lib/Makefile.am and gettext-tools/src/Makefile.am to get
the mbrtowc function. However, the current work-around is to export
LIBS="-lmsvcp60" but the build process should work out-of-the-box ...
msvcp60.dll is not part of a standard Windows2000 installation. Therefore
it would be not good to distribute binaries linked against this DLL, or to
assume its existence. Instead, an autoconf test should be added to test
for the existence of mbrtowc() in the _standard_ library.

The current test only requires that it's defined in the header files. The .m4 file where this test is defined comes from gnulib. However, I attached a patch (gettext_usable_mbrtowc.patch) that adds the compile & link test and modified the sources to check for HAVE_USABLE_MBRTOWC ...

BTW: I saw at several places some tests like #if HAVE_MBRTOWC or #if !HAVE_MBRTOWC. Those tests may fail with some preprocessors when HAVE_MBRTOWC isn't defined.

3. -lc must not be used on the MinGW platform

The libc simply doesn't exist on MinGW. This affects
gettext-tools/lib/Makefile.am and gettext-tools/src/Makefile.am.
Unfortunately, if I remove the "-lc", we get linker errors on different
platforms (like AIX, OSF/1 or BeOS, IIRC). Yeah, libtool...

For a current work-around, I changed configure.ac to set the LIBS_LIBC depending on the target type and replacing it in the Makefile.am files. The patch is gettext_conditional_libc.patch.

4. Accessing variables in shared libraries

The auto-import for variables from DLLs can fail on the MinGW (Win32)
platform when you:
- query the variables address (causes an exception fault)
- use something like "plural_table[i].lang", the auto-import simply fails

I attached a patch that fixes this problem.
These are extensive modifications for code that should work perfectly fine
when you compile with --disable-shared. The MSVC port uses a different
workaround: compile the files
 po-error.c
 format.c
 msgmerge.c
 xgettext.c
 msgattrib.c
 msgcat.c
 msgcomm.c
 msgconv.c
 msgen.c
 msgfilter.c
 msggrep.c
 msguniq.c
in C++ mode. Does this workaround also work with mingw? To put it in place,
you would only need to add "-x c++" to a few CFLAGS settings.
I tried it but I had to fix much source code that's invalid in C++. Maybe those "fixes" are interesting for you too? I'll send the patch to you directly (has a size of > 140k). I guess that some parts of this patch belong to other projects ...

BTW: It seemed that you updated (changed?) the "readlink.c" file. It gets compiled even when HAVE_READLINK is not defined.

But back to my test: No, it didn't help. Sorry. It seems to be a historical problem of binutils/gcc ...

5. When making a "make install", it recurses into
gettext-tools/examples/hello-c. AFAIK this is an error too because it
prevents a make install from completion.

Yes, "make install" is not meant to recurse into any of the hello-*
directories. How come? How to fix it?
Sorry, it was my fault: "make install" doesn't recurse into the hello-* directories. The problem is that it cannot create all those .po files required to execute the install-data-local rule in the examples/Makefile.am. Where can I find those .po files?

BTW: autoconf/automake complained about a missing AM_PROG_CC_C_O in gettext-runtime/configure.ac and gettext-tools/configure.ac. Any idea why this is needed?

The messages are:
src/Makefile.am:41: compiling `envsubst.c' with per-target flags requires `AM_PROG_CC_C_O' in `configure.ac' src/Makefile.am:154: compiling `hostname.c' with per-target flags requires `AM_PROG_CC_C_O' in `configure.ac'

Another problem is that libtool support for MinGW/MSYS is badly broken and the maintainer is very unfriendly :-(

Regards,
Mark Junker

Index: gettext-tools/configure.ac
===================================================================
RCS file: /cvs/gettext/gettext/gettext-tools/configure.ac,v
retrieving revision 1.50
diff -u -r1.50 configure.ac
--- gettext-tools/configure.ac  20 May 2005 21:06:01 -0000      1.50
+++ gettext-tools/configure.ac  8 Jun 2005 03:06:04 -0000
@@ -228,6 +252,19 @@
     ;;
 esac
 
+
+dnl Checking for the LIBC libraries to be added by default
+case "${host}" in
+  *-mingw* )
+    LIBS_LIBC=
+    ;;
+  *)
+    LIBS_LIBC=-lc
+    ;;
+esac
+AC_SUBST(LIBS_LIBC)
+
+
 dnl Check for Emacs and where to install .elc files.
 AM_PATH_LISPDIR
 
Index: gettext-tools/src/Makefile.am
===================================================================
RCS file: /cvs/gettext/gettext/gettext-tools/src/Makefile.am,v
retrieving revision 1.42
diff -u -r1.42 Makefile.am
--- gettext-tools/src/Makefile.am       20 May 2005 21:06:04 -0000      1.42
+++ gettext-tools/src/Makefile.am       6 Jun 2005 09:41:11 -0000
@@ -161,7 +161,7 @@
 # use iconv().
 libgettextsrc_la_LDFLAGS = \
   -release @VERSION@ \
-  ../lib/libgettextlib.la @LTLIBINTL@ @LTLIBICONV@ -lc -no-undefined
+  ../lib/libgettextlib.la @LTLIBINTL@ @LTLIBICONV@ @LIBS_LIBC@ -no-undefined
 
 # No need to install libgettextsrc.a, except on AIX.
 install-exec-local: install-libLTLIBRARIES install-exec-clean
Index: gettext-tools/lib/Makefile.am
===================================================================
RCS file: /cvs/gettext/gettext/gettext-tools/lib/Makefile.am,v
retrieving revision 1.41
diff -u -r1.41 Makefile.am
--- gettext-tools/lib/Makefile.am       20 May 2005 21:06:01 -0000      1.41
+++ gettext-tools/lib/Makefile.am       6 Jun 2005 09:41:01 -0000
@@ -121,7 +121,7 @@
 # Need @LTLIBICONV@ because linebreak.c uses iconv().
 libgettextlib_la_LDFLAGS = \
   -release @VERSION@ \
-  @LTLIBINTL@ @LTLIBICONV@ -lc -no-undefined
+  @LTLIBINTL@ @LTLIBICONV@ @LIBS_LIBC@ -no-undefined
 
 # No need to install libgettextlib.a, except on AIX.
 install-exec-local: install-libLTLIBRARIES install-exec-clean
Index: gettext-tools/lib/csharpcomp.sh.in
===================================================================
RCS file: /cvs/gettext/gettext/gettext-tools/lib/csharpcomp.sh.in,v
retrieving revision 1.4
diff -u -r1.4 csharpcomp.sh.in
--- gettext-tools/lib/csharpcomp.sh.in  20 May 2005 21:06:02 -0000      1.4
+++ gettext-tools/lib/csharpcomp.sh.in  8 Jun 2005 01:50:21 -0000
@@ -97,7 +97,7 @@
     -l)
       options_cscc="$options_cscc -l "`echo "$2" | sed -e "$sed_quote_subst"`
       options_mcs="$options_mcs -r "`echo "$2" | sed -e "$sed_quote_subst"`
-      options_csc="$options_csc -reference:"`echo "$2" | sed -e 
"$sed_quote_subst"`
+      options_csc="$options_csc -reference:"`echo "$2" | sed -e 
"$sed_quote_subst"`".dll"
       shift
       ;;
     -O)
Index: gettext-tools/config.h.in
===================================================================
RCS file: /cvs/gettext/gettext/gettext-tools/config.h.in,v
retrieving revision 1.5
diff -u -r1.5 config.h.in
--- gettext-tools/config.h.in   24 Feb 2005 19:39:15 -0000      1.5
+++ gettext-tools/config.h.in   8 Jun 2005 02:37:51 -0000
@@ -310,6 +310,10 @@
 /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
 #undef HAVE_NDIR_H
 
+/* Define if you have <langinfo.h> and it defines the NL_LOCALE_NAME macro if
+   _GNU_SOURCE is defined. */
+#undef HAVE_NL_LOCALE_NAME
+
 /* Define to 1 if you have the <nl_types.h> header file. */
 #undef HAVE_NL_TYPES_H
 
@@ -417,6 +421,9 @@
 /* Define to 1 if you have the `strtoul' function. */
 #undef HAVE_STRTOUL
 
+/* Define to 1 if `__names' is member of `struct __locale_struct'. */
+#undef HAVE_STRUCT___LOCALE_STRUCT___NAMES
+
 /* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
    */
 #undef HAVE_SYS_DIR_H
@@ -461,6 +468,9 @@
 /* Define if you have the 'unsigned long long' type. */
 #undef HAVE_UNSIGNED_LONG_LONG
 
+/* Define to 1 if mbrtowc and mbstate_t can be found in standard libraries. */
+#undef HAVE_USABLE_MBRTOWC
+
 /* Define to 1 if you have the `utime' function. */
 #undef HAVE_UTIME
 
@@ -554,6 +564,9 @@
 /* If malloc(0) is != NULL, define this to 1. Otherwise define this to 0. */
 #undef MALLOC_0_IS_NONNULL
 
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+#undef NO_MINUS_C_MINUS_O
+
 /* Name of package */
 #undef PACKAGE
 
@@ -599,6 +612,9 @@
 /* Define to 1 if strerror_r returns char *. */
 #undef STRERROR_R_CHAR_P
 
+/* Define to the header that declares multithreading facilities. */
+#undef THREAD_H
+
 /* Define to 1 if you want getc etc. to use unlocked I/O if available.
    Unlocked I/O can improve performance in unithreaded apps, but it is not
    safe for multithreaded apps. */
@@ -665,7 +681,7 @@
 /* Define to `int' if <sys/types.h> does not define. */
 #undef mode_t
 
-/* Define to `long' if <sys/types.h> does not define. */
+/* Define to `long int' if <sys/types.h> does not define. */
 #undef off_t
 
 /* Define to `int' if <sys/types.h> does not define. */
@@ -689,7 +705,7 @@
 /* Define to empty if the C compiler doesn't support this keyword. */
 #undef signed
 
-/* Define to `unsigned' if <sys/types.h> does not define. */
+/* Define to `unsigned int' if <sys/types.h> does not define. */
 #undef size_t
 
 /* Define as a signed type of the same size as size_t. */
@@ -703,6 +719,9 @@
 #undef vfork
 
 
+/* Indicator for intl/ that it is compiled for testing purposes only.  */
+#define USE_IN_GETTEXT_TESTS
+
 /* A file name cannot consist of any character possible.  INVALID_PATH_CHAR
    contains the characters not allowed.  */
 #if defined _MSC_VER || defined __MINGW32__
Index: gettext-tools/configure.ac
===================================================================
RCS file: /cvs/gettext/gettext/gettext-tools/configure.ac,v
retrieving revision 1.50
diff -u -r1.50 configure.ac
--- gettext-tools/configure.ac  20 May 2005 21:06:01 -0000      1.50
+++ gettext-tools/configure.ac  8 Jun 2005 02:22:03 -0000
@@ -160,6 +162,28 @@
 gl_XSIZE
 gt_LIBGREP
 
+AC_CACHE_CHECK([whether mbrtowc and mbstate_t are *really* usable],
+  gl_cv_func_mbrtowc_usable,
+  [AC_RUN_IFELSE(
+     [
+       #include <wchar.h>
+       
+       int main(int argc, char **argv)
+       {
+         mbstate_t state;
+         mbrtowc(NULL, "", 1, &state);
+         return 0;
+       }
+     ],
+     gl_cv_func_mbrtowc_usable=yes,
+     gl_cv_func_mbrtowc_usable=no)
+  ]
+)
+if test $gl_cv_func_mbrtowc_usable = yes; then
+  AC_DEFINE(HAVE_USABLE_MBRTOWC, 1,
+    [Define to 1 if mbrtowc and mbstate_t can be found in standard libraries.])
+fi
+
 gt_PREREQ_HOSTNAME
 
 dnl These are the only lines required to internationalize the package.
Index: gettext-tools/lib/mbswidth.c
===================================================================
RCS file: /cvs/gettext/gettext/gettext-tools/lib/mbswidth.c,v
retrieving revision 1.5
diff -u -r1.5 mbswidth.c
--- gettext-tools/lib/mbswidth.c        20 May 2005 21:06:02 -0000      1.5
+++ gettext-tools/lib/mbswidth.c        8 Jun 2005 02:36:41 -0000
@@ -110,7 +110,7 @@
   int width;
 
   width = 0;
-#if HAVE_MBRTOWC
+#if defined(HAVE_MBRTOWC) && defined(HAVE_USABLE_MBRTOWC)
   if (MB_CUR_MAX > 1)
     {
       while (p < plimit)
Index: gettext-tools/lib/quotearg.c
===================================================================
RCS file: /cvs/gettext/gettext/gettext-tools/lib/quotearg.c,v
retrieving revision 1.3
diff -u -r1.3 quotearg.c
--- gettext-tools/lib/quotearg.c        20 May 2005 21:06:02 -0000      1.3
+++ gettext-tools/lib/quotearg.c        8 Jun 2005 02:35:22 -0000
@@ -47,7 +47,7 @@
 # include <wchar.h>
 #endif
 
-#if !HAVE_MBRTOWC
+#if !defined(HAVE_MBRTOWC) || !defined(HAVE_USABLE_MBRTOWC)
 /* Disable multibyte processing entirely.  Since MB_CUR_MAX is 1, the
    other macros are defined only for documentation and to satisfy C
    syntax.  */
Index: gettext-tools/libgrep/dfa.c
===================================================================
RCS file: /cvs/gettext/gettext/gettext-tools/libgrep/dfa.c,v
retrieving revision 1.6
diff -u -r1.6 dfa.c
--- gettext-tools/libgrep/dfa.c 20 May 2005 21:06:02 -0000      1.6
+++ gettext-tools/libgrep/dfa.c 8 Jun 2005 02:35:35 -0000
@@ -31,7 +31,7 @@
 #include <string.h>
 #include <locale.h>
 
-#if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC
+#if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC && 
defined HAVE_USABLE_MBRTOWC
 /* We can handle multibyte string.  */
 # define MBS_SUPPORT
 #endif
Index: gettext-tools/libgrep/m-common.h
===================================================================
RCS file: /cvs/gettext/gettext/gettext-tools/libgrep/m-common.h,v
retrieving revision 1.2
diff -u -r1.2 m-common.h
--- gettext-tools/libgrep/m-common.h    20 May 2005 21:06:02 -0000      1.2
+++ gettext-tools/libgrep/m-common.h    8 Jun 2005 02:35:50 -0000
@@ -20,7 +20,7 @@
 #include <limits.h>
 #include "kwset.h"
 
-#if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC
+#if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC && 
defined HAVE_USABLE_MBRTOWC
 /* We can handle multibyte string.  */
 # define MBS_SUPPORT
 # include <wchar.h>

reply via email to

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