Search code examples
cross-compilingglibundeclared-identifier

Cross-compiling GLib for Windows is throwing an error "'XDG_MIME_TYPE_UNKNOWN' undeclared"


While cross-compiling GLib 2.32.4 with Mingw-w64 for Win32, I ran into the following error:

gcontenttype.c: In function 'g_content_type_guess':
gcontenttype.c:335:3: error: 'XDG_MIME_TYPE_UNKNOWN' undeclared (first use in this function)
gcontenttype.c:335:3: note: each undeclared identifier is reported only once for each function it appears in

I can only assume one of two things:

  • I am missing some sort of preprocessor definition or ./configure flag (currently I only pass --host and --prefix to ./configure).

  • There is an error in the source code.

Some further digging around revealed that XDG_MIME_TYPE_UNKNOWN is defined gio/xdgmime/xdgmime.h like so:

extern const char xdg_mime_type_unknown[];
#define XDG_MIME_TYPE_UNKNOWN xdg_mime_type_unknown

This file doesn't seem to be included anywhere in gcontenttype.c however.

Is this a problem with the way I am compiling the library or is it a bug with the library?


Solution

  • I finally just fixed up the source code myself.

    gcontenttype.c:335

    g_return_val_if_fail (data_size != (gsize) -1,
                          g_strdup (XDG_MIME_TYPE_UNKNOWN));
    

    ...becomes...

    g_return_val_if_fail (data_size != (gsize) -1,
                          g_strdup ("application/octet-stream"));
    

    The library now compiles without error.