« The Creation à la Infocom - and the Hitchhiker's Guide rides again | Main | California Ballot Propositions - 2004 election »

October 07, 2004

Building OpenBabel under MinGW

1. gettimeofday()

This post on Building GNU Chess 5.07 on MinGW/gcc actually addresses a general problem with MinGW - it doesn't support the gettimeofday() call.

This fix from Anders Carlsson addresses that:


---- In common.h after #include <sys/time>, I added the following:

/* These are winbase.h definitions, but to avoid including
tons of Windows related stuff, it is reprinted here */
typedef struct _FILETIME {
unsigned long dwLowDateTime;
unsigned long dwHighDateTime;
} FILETIME;
void __stdcall GetSystemTimeAsFileTime(FILETIME*);

void gettimeofday(struct timeval* p, void* tz /* IGNORED */);

---- and into main.c, I put the actual gettimeofday function:

void gettimeofday(struct timeval* p, void* tz /* IGNORED */){
union {
long long ns100; /*time since 1 Jan 1601 in 100ns units */
FILETIME ft;
} _now;

GetSystemTimeAsFileTime( &(_now.ft) );
p->tv_usec=(long)((_now.ns100 / 10LL) % 1000000LL );
p->tv_sec= (long)((_now.ns100-(116444736000000000LL))/10000000LL);
return;
}

----

Anders's original post was in the Redhat GDB mailing list.

2. rindex()

rindex() is unresolved ...

Danny Smith has this to say on the MinGW forum on SourceForge:

index, rindex are non-ANSI version of strchr. strrchr respectivley.
 msvcrt.dll exports only the ANSI names.  
   
 Change the references to the non-ANSI names to strchr and strrchr ... 

3. Still working on it ... currently having problems with resolving stdcall namemangled GetSystemTimeAsFileTime()

...

Posted by daen at October 7, 2004 01:17 AM