2011年11月11日 星期五

Compile nec2c with MinGW64

There are two problems.

1. There's no sys/times.h in MinGW32 or MinGW64. We have to write it ourselves.
2. The default fprintf() does not handle 80-bit long double.

I reference the article HERE to solve the first problem.
Instead of out of cygwin, I pulled out the structure definition from Ubuntu /usr/x86_64-linux-gnu/sys/times.h
-------------------------------------------------------------------------------------
/* put these lines in the header file. */


struct tms
  {
    clock_t tms_utime; /* User CPU time.  */
    clock_t tms_stime; /* System CPU time.  */

    clock_t tms_cutime; /* User CPU time of dead children.  */
    clock_t tms_cstime; /* System CPU time of dead children.  */
  };

clock_t  times( struct tms *buffer );


-------------------------------------------------------------------------------------
/* and put these in one .c file you like. I chose misc.c */

clock_t  times( struct tms *buffer )
{

buffer->tms_utime         = clock();
buffer->tms_stime         = clock();
buffer->tms_cutime = clock();
buffer->tms_cstime = clock();

return clock();
}

-------------------------------------------------------------------------------------


The second one is easier to solve, HERE are two solutions.
I used the easy one. Put the following line  before include anything.

#define  __USE_MINGW_ANSI_STDIO 1

There are some minor problems.
I simply comment line 80, line 131 to 146 and line 1996 to 2023 in main.c.

That's it.

沒有留言:

張貼留言