[GRASS-dev] Compilation errors under MinGW

Glynn Clements glynn at gclements.plus.com
Wed Dec 3 20:51:26 EST 2008


Rosen Matev wrote:

> There are a few errors that popped out when I tried to compile MinGW.
> As far as I can see only trunk is faulty. I solved the problem by
> updating the problematic files from an older revision. Here is the
> summary:
> 
> COMPILATION ERRORS //in mingw environment
> (revision 34688)
> 
> /trunk/lib/gis
>     locale.c:33: error: `LC_MESSAGES' undeclared (first use in this function)
>     // the problem is in locale.h bundled with mingw
>     // probably not GRASS' issue but I'm not sure

Okay. LC_MESSAGES is POSIX, not ANSI C. I'll conditionalise that upon
"#ifdef LC_MESSAGES" and move it into the "#if ... defined(USE_NLS)"
part. It isn't meaningful if you aren't building with NLS enabled.

>     mach_name.c:34:6: #if with no expression
>     // the #elif at #34 should be #else

Okay.

>     popen.c:55: error: `popen_pid' undeclared (first use in this function)
>     // what's the best way to fix this?

With:

	G_fatal_error("G_popen() not implemented on Windows")

That code was broken in the first place. Previously, it would compile
but wouldn't work:

1. popen_pid[f] wasn't being set in the MinGW version of G_popen(),
but more significantly ...

2. The MinGW version of G_popen() uses execl(), which effectively
terminates the calling process. It should use _spawnl(_P_NOWAIT).

3. It creates the pipe, but doesn't make the child process use it as
its stdin/stdout. AFAIK, the only way to do this with _spawnl() (or
similar CRT functions) is for the caller to _dup2() its own
stdin/stdout, call _spawnl(), then restore the original descriptor. 
See lib/db/dbmi_client/start.c.

>     spawn.c: In function `G_spawn':

Ugh; I forgot to do the MinGW cases when I updated this.

> The fix should be straightforward. I can't commit to trunk so I'm
> letting you know for these.

Can you test r34695?

> Please elaborate on the first error. I fixed it by adding a line
> "#define LC_MESSAGES 6" in locale.h, which pretty lame.

The setlocale() in MSVCRT doesn't understand LC_MESSAGES, so the call
needs to be disabled there. I don't know how gettext handles this on
Windows.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list