[Mono-devel-list] libintl does not work on windows?

Jonathan Pryor jonpryor at vt.edu
Fri Mar 4 07:40:11 EST 2005


On Fri, 2005-03-04 at 02:03 +0100, Fabian Sturm wrote:
> Hi!
> 
> I have the simple problem that I can't use libintl on windows.

Do you have libintl.dll installed?

> A call to Mono.Unix.Catalog in mono-1.1.4 on windows produces:
> 
>  Unhandled Exception: System.DllNotFoundException: libc.so.6
>  in <0x00049> (wrapper managed-to-native)  
>  Mono.Unix.Catalog:bindtextdomain (intptr,intptr)
>  in <0x0002e> Mono.Unix.Catalog:Init (string,string)
>  in <0x0001d> TranslationTest:.ctor (string[])
>  in <0x0001d> TranslationTest:Main (string[])
> 
> I do not understand where it references the libc.so.6?

I know what the problem is.  And I know of a solution for you.  But I
don't know what the correct, long-term solution is (suggestions
welcome).

The problem is this: following standard procedure, Mono.Unix.Catalog
DllImports libintl.dll, as that library exists on Windows.  However,
libintl.dll doesn't exist on all Unix platforms; the functions it
exports are usually part of libc.  Consequently, $prefix/etc/mono/config
contains a <dllmap/> redirecting libintl.dll to libc.so, which is why
you're seeing a DllNotFoundException for libc.so: mono is redirecting
libintl.dll to libc.so, even though the platform you're on doesn't
require such redirections.

This same issue will effect every library listed in
$prefix/etc/mono/config, including odbc32.dll, libmySQL.dll, and
cygwin1.dll (i.e. if your app depends on any of those libraries and runs
on mono/Win32, it will break due to the dll mapping).

The short-term solution for you is to edit $prefix/etc/mono/config and
remove the <dllmap/> elements for libintl and MonoPosixHelper.  You will
still need to have libintl.dll in your path, which is why I asked above.

I can see three long-term solutions to this:

 1. Ignore $prefix/etc/mono when running on Windows, on the assumption 
    that all assemblies will use Windows library names by default, 
    rendering the dll mapping pointless.
    Pros: 
      - This simplifies things, as you can assume (ha!) that the .config
        files will only be read on a non-windows system.
        Currently it seems that the .config file is read before probing
        for the DLL, so if e.g. Gtk# installed the .config files on 
        Windows, Mono will try to load libgtk-x11-2.0.so instead of 
        libgtk-win32-2.0-0.dll, which would be incorrect.
      - Mono acts more like .NET on Windows, as .NET doesn't have a
        dllmap capability.
    Con:
      - Mono doesn't act consistently across all platforms.

 2. Edit $prefix/etc/mono/config before creating the install program to
    remove all <dllmap/> elements, as they're superfluous on win32.
    (This is an evil solution, as it requires manual intervention.)

 3. Probe for the DllImport assembly *before* reading the relevant 
    config file and loading the mapped assembly.  This will provide
    consistent behavior across all platforms, and allow the correct
    win32 libraries to be found when running on win32.

 - Jon

PS: for all I know (3) is actually done.  I don't have time to test this
right now or read the source...





More information about the Mono-devel-list mailing list