[Radiance-dev] Radiance compiled with mingw gcc (windows)

Francesco Anselmo francesco.anselmo at arup.com
Sun Sep 11 15:09:37 CEST 2005


Hi all!

I've finally started looking at rtcontrib to replace my own scripts to
calculate daylight coefficients, and need to use it with windows
(unfortunately!) and without cygwin, so I've been "forced" to try the mingw
(http://www.mingw.org/) version of gcc to compile Radiance.

Scons has worked pretty well to compile most of the console programs. 
I used these variables in platform\win32_custom.cfg:

[build]
CPPDEFINES: _WIN32 NDEBUG _CONSOLE _MBCS NON_POSIX
CC:        gcc
CCFLAGS:   -O2 -DHDSUF=.exe

[code]
RAD_SPEED: -DSPEED=200 -DHDSUF=.exe
RAD_COMPAT: fixargv0.c
RAD_MATHCOMPAT: erf.c
RAD_MEMCOMPAT: 
RAD_MLIB:   m
RAD_PROCESS: win_process.c win_popen.c

and had to manually add some extra RAD_COMPAT inside a couple of SConstruct files
(maybe somebody can suggest a better CPPDEFINES line ...).

As for the source files: 

1.
I had to redefine kill() inside rad.c and ranimate.c
using "RT_PID pid" instead of "int pid":

int
kill(RT_PID pid, int sig) /* win|unix_process.c should also wait and kill */
{
	return 0;
}

Also, inside win_process.c for the close_process() function:
was -----------------> int win_kill(pid, 0);
i've changed it to --> win_kill(pid, 0);

2.
The mingw version of signal.h doesn't have a definition for SIGALRM, so
killpersist() inside mkillum.c needs to be changed:
It is like this:
if (fscanf(fp, "%*s %d", &pid) != 1 || kill(pid, SIGALRM) < 0)
but I've used SIGTERM instead of SIGALRM, don't know if this make much sense ...

3.
rtcontrib was calling rtrace with a wrong command line. It was something like
this:

c:\radiance\bin/rtrace.exe rtrace [args ...]

After some little searching I used this quick workaround inside win_process.c

	        cmdpath = getpath(av[0], getenv("PATH"), X_OK);
added by me -->	av[0] = "";
	        cmdstr = quoted_cmdline(cmdpath, av);

that may have broken something somewhere else, so probably
a better solution would be to do some extra checks inside the _WIN32 section
of getpath.c.

I am interested only in rtcontrib right now, so I haven't checked
if other programs that call open_process() are still working or not.

4.
Mingw doesn't have fseeko(), and I replaced it with fseek() inside rtcontrib.c.
This seems to have broken the file output, that is working well with both
cygwin and linux. Is there an easy workaround for this? I don't have very
much experience to figure it out myself. Output to stdout now works fine ...

I hope not to have forgotten anything.

Sorry for the long email and thanks in advance,

Francesco



More information about the Radiance-dev mailing list