Main.OpenBabel History

Hide minor edits - Show changes to markup

March 16, 2009, at 06:45 PM by 148.187.130.153 -
Changed line 3 from:

NOTE: This page is left for reference; Molekel is not however using MinGW anymore as the main Windows build environment, it is therefore not required to have a MinGW build of OpenBabel.

to:

NOTE: This page is left for reference; Molekel is not however using MinGW anymore as the main Windows build environment, it is therefore not required to have a MinGW build of OpenBabel.

March 16, 2009, at 06:44 PM by 148.187.130.153 -
Added lines 2-3:

NOTE: This page is left for reference; Molekel is not however using MinGW anymore as the main Windows build environment, it is therefore not required to have a MinGW build of OpenBabel.

March 16, 2009, at 06:42 PM by 148.187.130.153 -
Changed line 1 from:

OpenBabel and MinGW

to:

(:title OpenBabel and MinGW :)

June 29, 2007, at 12:10 AM by 84.74.33.192 -
Added line 13:

/*depending on the version of gcc installed you might or might not have hash_map in the include path.*/

Changed lines 15-17 from:
  //typedef stdext::hash_map<std::string, unsigned> NameIndexType;

//#else

  typedef std::map<std::string, unsigned> NameIndexType;
to:

// #include <hash_map>

Added lines 17-24:

...

//#ifdef _WIN32

  //typedef stdext::hash_map<std::string, unsigned> NameIndexType;

//#else

  typedef std::map<std::string, unsigned> NameIndexType;

//#endif

June 27, 2007, at 04:47 PM by 148.187.130.131 -
Changed line 22 from:

OpenBabel does need the gettimeofday() function which might or might not be available in the MinGW installation; in case you install MinGW 5.1.3 (gcc 3.4.2) the function should be available as

to:

OpenBabel does need the gettimeofday() function which might or might not be available in your MinGW environment; in case you install MinGW 5.1.3 (gcc 3.4.2) the function should be available as

Changed lines 28-29 from:

Note that mingw-runtime 3.12 or later should contain a proper implementation of gettimeofday().

to:

Also note that mingw-runtime 3.12 or later should contain a proper implementation of gettimeofday().

June 27, 2007, at 04:46 PM by 148.187.130.131 -
Changed line 22 from:

OpenBabel does need the gettimeofdaty() function which might or might not be available in the MinGW installation; in case you install MinGW 5.1.3 (gcc 3.4.2) the function should be available as

to:

OpenBabel does need the gettimeofday() function which might or might not be available in the MinGW installation; in case you install MinGW 5.1.3 (gcc 3.4.2) the function should be available as

June 27, 2007, at 04:45 PM by 148.187.130.131 -
Changed lines 28-30 from:

In case the function is not available, you can simply replace include/sys/time.h with an include containing the following code:

to:

Note that mingw-runtime 3.12 or later should contain a proper implementation of gettimeofday().

If the function is not available, you can simply replace include/sys/time.h with an include containing the following code:

Changed lines 101-102 from:

If you try to build OpenBabel 2.0.2 on Windows with MinGW you should get something similar to the following:

to:

If you try to build OpenBabel 2.0.2 on Windows with MinGW you might get something similar to the following:

Changed lines 111-112 from:

The compiler is complaining about a missing function; gettimeofday is in fact missing in a MinGW environment.

to:

The compiler is complaining about a missing function; gettimeofday is in fact missing in some MinGW environments (mingw-runtime 3.12 or better should contain a proper implementation of gettimeofday).

June 27, 2007, at 04:33 PM by 148.187.130.131 -
Changed line 3 from:

OpenBabel doesn't build out of the box with MinGW, this section describes how to build OpenBabel 2.0.2 and 2.1 (libs only) on Windows with MinGW.

to:

OpenBabel doesn't build out of the box with MinGW, this page describes how to build OpenBabel 2.0.2 and 2.1 (libs only) on Windows with MinGW.

June 27, 2007, at 04:32 PM by 148.187.130.131 -
Changed line 3 from:

OpenBabel doesn't build out of the box with MinGW, this section describes how to build OpenBabel 2.0.2 on Windows with MinGW.

to:

OpenBabel doesn't build out of the box with MinGW, this section describes how to build OpenBabel 2.0.2 and 2.1 (libs only) on Windows with MinGW.

Deleted lines 5-7:

Following the instructions on this page you'll be able to build all the libraries and tools except for obgrep which has a dependency on a library which is not included in the OpenBabel distribution: XGetopt and that you can download from here: http://www.codeproject.com/cpp/xgetopt.asp?df=100.

Changed lines 8-9 from:

If you try to build OpenBabel 2.0.2 on Windows with MinGW you should get something similar to the following:

to:

OpenBabel 2.1 (libs only)

1 - hash_map

When building OB 2.1 on MinGW you need to disable the usage of hash_map in obmolecformat.h: simply comment the lines where this class is used:

Changed lines 13-17 from:

./configure ... make ... ../../src/obutil.h:73: error: `gettimeofday' undeclared (first use this function)

to:

//#ifdef _WIN32

  //typedef stdext::hash_map<std::string, unsigned> NameIndexType;

//#else

  typedef std::map<std::string, unsigned> NameIndexType;

//#endif @] Note that stdext::hash_map is MS version of something similar to tr1::unordered_map and GCC's __gnu_cxx::hash_map which is in fact a modified version of SGI's ::hash_map; these data types are not however compatible with each other(try to replace stdext::hash_map with __gnu_cxx::hash_map and check the error you get).

2 - gettimeofday()

OpenBabel does need the gettimeofdaty() function which might or might not be available in the MinGW installation; in case you install MinGW 5.1.3 (gcc 3.4.2) the function should be available as [@ int __cdecl gettimeofday(struct timeval *__restrict__,

			 void *__restrict__  /*	tzp (unused) */);
Changed lines 28-32 from:

The compiler is complaining about a missing function; gettimeofday is in fact missing in a MinGW environment.

To fix this you can do the following:

1. Open src/babelconfig.h.in and add the following declaration:

to:

In case the function is not available, you can simply replace include/sys/time.h with an include containing the following code:

Changed lines 30-90 from:

void gettimeofday( struct timeval* p, void* );

to:
  1. ifndef _SYS_TIME_H_
  2. define _SYS_TIME_H_
  3. include <time.h>
  4. include <windows.h>
  5. ifndef _TIMEVAL_DEFINED /* also in winsock[2].h */
  6. define _TIMEVAL_DEFINED

struct timeval {

  long tv_sec;
  long tv_usec;

};

  1. define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
  2. define timercmp(tvp, uvp, cmp) (((tvp)->tv_sec != (uvp)->tv_sec) ? ((tvp)->tv_sec cmp (uvp)->tv_sec) : ((tvp)->tv_usec cmp (uvp)->tv_usec))
  3. define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
  4. endif /* _TIMEVAL_DEFINED */

/* Provided for compatibility with code that assumes that

   the presence of gettimeofday function implies a definition
   of struct timezone. */

struct timezone {

  int tz_minuteswest; /* of Greenwich */
  int tz_dsttime;     /* type of dst correction to apply */

};

/*

   Implementation as per:
   The Open Group Base Specifications, Issue 6
   IEEE Std 1003.1, 2004 Edition

   The timezone pointer arg is ignored.  Errors are ignored.
  • /
  1. ifdef __cplusplus

void GetSystemTimeAsFileTime(FILETIME*);

inline int 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 0;

}

  1. else
    /* Must be defined somewhere else */
int gettimeofday(struct timeval* p, void* tz /* IGNORED */);
  1. endif
  2. endif /* _SYS_TIME_H_ */
Changed lines 93-108 from:

If you build now you get a brand new error message: bondtyper.cpp:21: bondtyp.h: No such file or directory

The problem is that there are a number of files in the data dir which need to be accessible and they are not because this directory is not in the include path, here is part of the gcc command line you get when invoking make: -I. -I. -I. -I../data

To fix this problem you need to add the data dir (where the bondtyp.h resides) to the include path.

2. before running ./configure set the CPPFLAGS evironment variable: export CPPFLAGS="-I <absolute path to data dir>"

Now everything compiles but doesn't link yet because there is no definition of function gettimeofday so in case you try to link you get the following error: undefined reference to `gettimeofday( timeval*, void* ) We need to write the definition of this function in a c++ file and then modify the makefile to include this new source file.

3. create a file gettimeofday.cpp and add the following code into it:

to:

That's it. With these two changes you'll be able to build the inchi and openbabel libraries.

OpenBabel 2.0.x

Following the instructions in this section you'll be able to build all the libraries and tools except for obgrep which has a dependency on a library which is not included in the OpenBabel distribution: XGetopt and that you can download from here: http://www.codeproject.com/cpp/xgetopt.asp?df=100.

If you try to build OpenBabel 2.0.2 on Windows with MinGW you should get something similar to the following:

Changed lines 102-117 from:
   #include <windows.h>
   #include <sys/time.h>

   void __stdcall GetSystemTimeAsFileTime(FILETIME*);

   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);
   }
to:

./configure ... make ... ../../src/obutil.h:73: error: `gettimeofday' undeclared (first use this function)

Changed lines 109-119 from:

4. Modify Makefile.in adding gettimeofday.cpp to the list of source files: [@ ...

   @BUILD_SHARED_TRUE@ fingerprints/libfingerprints.la @LTLIBOBJS@
   am__libopenbabel_la_SOURCES_DIST = gettimeofday.cpp atom.cpp base.cpp bitvec.cpp    ...
   @BUILD_SHARED_TRUE@am__objects_1 = dlhandler_unix.lo
   am_libopenbabel_la_OBJECTS = gettimeofday.lo base.lo bitvec.lo bond.lo    ...
   libopenbabel_la_SOURCES = 		gettimeofday.cpp atom.cpp base.cpp bitvec.cpp bond.cpp    ...
to:

The compiler is complaining about a missing function; gettimeofday is in fact missing in a MinGW environment.

To fix this you can do the following:

1. Open src/babelconfig.h.in and add the following declaration: [@ void gettimeofday( struct timeval* p, void* );

Changed lines 117-127 from:

If you build it with the current configuration you will incur in another problem: the dynamic library handler is set to unix

5. substitute all the instances of dlhandler_unix.xxx in Makefile.in with dlhandler_win32.xxx, there should be a total of five occurrences in the file. The use of a dynamic library handler should be automatically enabled when shared library support is turned on (default). In case dlhandler is set to null in Makefile you'll have to manually remove @BUILD_SHARED_TRUE@ in front of am_objects_1 AND dlhandler =dlhandler_win32.cpp you have to do this if you get a link error about an undefined symbol __imp_XXXDLHandler9openFileXXXX

At this point the libraries build but not the executables.

6. if you want to build the executables you'll have to open all the cpp files in the test and tools folder and comment #define USING_OBDLL i.e.

to:

If you build now you get a brand new error message: bondtyper.cpp:21: bondtyp.h: No such file or directory

The problem is that there are a number of files in the data dir which need to be accessible and they are not because this directory is not in the include path, here is part of the gcc command line you get when invoking make: -I. -I. -I. -I../data

To fix this problem you need to add the data dir (where the bondtyp.h resides) to the include path.

2. before running ./configure set the CPPFLAGS evironment variable: export CPPFLAGS="-I <absolute path to data dir>"

Now everything compiles but doesn't link yet because there is no definition of function gettimeofday so in case you try to link you get the following error: undefined reference to `gettimeofday( timeval*, void* ) We need to write the definition of this function in a c++ file and then modify the makefile to include this new source file.

3. create a file gettimeofday.cpp and add the following code into it:

Changed lines 135-138 from:

// used to set import/export for Cygwin DLLs

  1. ifdef WIN32

//#define USING_OBDLL

  1. endif
to:
   #include <windows.h>
   #include <sys/time.h>

   void __stdcall GetSystemTimeAsFileTime(FILETIME*);

   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);
   }
Added lines 153-182:

4. Modify Makefile.in adding gettimeofday.cpp to the list of source files:

 ...
   @BUILD_SHARED_TRUE@ fingerprints/libfingerprints.la @LTLIBOBJS@
   am__libopenbabel_la_SOURCES_DIST = gettimeofday.cpp atom.cpp base.cpp bitvec.cpp \
   ...
   @BUILD_SHARED_TRUE@am__objects_1 = dlhandler_unix.lo
   am_libopenbabel_la_OBJECTS = gettimeofday.lo base.lo bitvec.lo bond.lo \
   ...
   libopenbabel_la_SOURCES = \
		gettimeofday.cpp atom.cpp base.cpp bitvec.cpp bond.cpp \
   ...

If you build it with the current configuration you will incur in another problem: the dynamic library handler is set to unix

5. substitute all the instances of dlhandler_unix.xxx in Makefile.in with dlhandler_win32.xxx, there should be a total of five occurrences in the file. The use of a dynamic library handler should be automatically enabled when shared library support is turned on (default). In case dlhandler is set to null in Makefile you'll have to manually remove @BUILD_SHARED_TRUE@ in front of am_objects_1 AND dlhandler =dlhandler_win32.cpp you have to do this if you get a link error about an undefined symbol __imp_XXXDLHandler9openFileXXXX

At this point the libraries build but not the executables.

6. if you want to build the executables you'll have to open all the cpp files in the test and tools folder and comment #define USING_OBDLL i.e.

// used to set import/export for Cygwin DLLs
#ifdef WIN32
//#define USING_OBDLL
#endif
January 04, 2007, at 06:56 PM by Ugo Varetto -
Changed lines 31-32 from:

@[bondtyper.cpp:21: bondtyp.h: No such file or directory@]

to:

bondtyper.cpp:21: bondtyp.h: No such file or directory

December 22, 2006, at 01:17 PM by Ugo Varetto -
Changed lines 21-22 from:

The compiler is complaining about a missing function; gettimeofday is in fact missing in a MinGW environment.

to:

The compiler is complaining about a missing function; gettimeofday is in fact missing in a MinGW environment.

December 21, 2006, at 04:24 PM by Ugo Varetto -
Deleted lines 0-1:

Update in progress

December 21, 2006, at 04:23 PM by Ugo Varetto -
Changed lines 83-84 from:

@in case dlhandler is set to null in Makefile you'll have to manually remove BUILD_SHARED_TRUE in front of am_objects_1 AND dlhandler =dlhandler_win32.cpp you have to do this if you get a link error about an undefined symbol __imp_XXXDLHandler9openFileXXXX

to:

In case dlhandler is set to null in Makefile you'll have to manually remove @BUILD_SHARED_TRUE@ in front of am_objects_1 AND dlhandler =dlhandler_win32.cpp you have to do this if you get a link error about an undefined symbol __imp_XXXDLHandler9openFileXXXX

December 21, 2006, at 04:22 PM by Ugo Varetto -
Changed lines 83-84 from:

@in case dlhandler is set to null in Makefile you'll have to manually remove @BUILD_SHARED_TRUE@ in front of am_objects_1 AND dlhandler =dlhandler_win32.cpp you have to do this if you get a link error about an undefined symbol __imp_XXXDLHandler9openFileXXXX

to:

@in case dlhandler is set to null in Makefile you'll have to manually remove BUILD_SHARED_TRUE in front of am_objects_1 AND dlhandler =dlhandler_win32.cpp you have to do this if you get a link error about an undefined symbol __imp_XXXDLHandler9openFileXXXX

December 21, 2006, at 04:20 PM by Ugo Varetto -
Changed lines 26-27 from:
  1. Open src/babelconfig.h.in
  2. Add the following declaration:
to:

1. Open src/babelconfig.h.in and add the following declaration:

Added line 31:
Added line 34:
Changed lines 37-38 from:

To fix this problem you need to add the data dir (where the bondtyp.h resides) to the include path:

  1. before running ./configure set the CPPFLAGS evironment variable:
to:

To fix this problem you need to add the data dir (where the bondtyp.h resides) to the include path.

2. before running ./configure set the CPPFLAGS evironment variable:

Added line 42:
Changed lines 46-47 from:
  1. create a file gettimeofday.cpp and add the following code into it:
to:

3. create a file gettimeofday.cpp and add the following code into it:

Changed lines 66-67 from:
  1. Modify Makefile.in adding gettimeofday.cpp to the list of source files:
to:

4. Modify Makefile.in adding gettimeofday.cpp to the list of source files:

Changed lines 78-79 from:

@]

to:

@]

Changed lines 81-82 from:
  1. substitute all the instances of dlhandler_unix.xxx in Makefile.in with dlhandler_win32.xxx, there should be a total of five occurrences in the file. The use of a dynamic library handler should be automatically enabled when shared library support is turned on (default).
to:

5. substitute all the instances of dlhandler_unix.xxx in Makefile.in with dlhandler_win32.xxx, there should be a total of five occurrences in the file. The use of a dynamic library handler should be automatically enabled when shared library support is turned on (default).

Added lines 84-85:

At this point the libraries build but not the executables.

Changed lines 87-102 from:

7) if you want to build the executables you'll have to open the cpp files in

   test and tools folder and comment #define USING_OBDLL

   // used to set import/export for Cygwin DLLs
   #ifdef WIN32
   //#define USING_OBDLL
   #endif

8) run configure --prefix=<installation folder> then make: this will build the

   libraries into src/.libs, and the executables in the src, tools and test folders.
   You can then run make install.
   Note that to have make install succeed you have to also fix obgrep.cpp so that it
   can somehow build: either you get the XGetopt library mentioned at the beginning
   of this document, build it with MinGW and link with it or you can simply comment
   the code in obgrep.cpp main function.
to:

6. if you want to build the executables you'll have to open all the cpp files in the test and tools folder and comment #define USING_OBDLL i.e.

// used to set import/export for Cygwin DLLs
#ifdef WIN32
//#define USING_OBDLL
#endif

7. run configure --prefix=<installation folder> then make: this will build the libraries into src/.libs, and the executables in the src, tools and test folders. You can then run make install. Note that to have make install succeed you have to also fix obgrep.cpp so that it can somehow build: either you get the XGetopt library mentioned at the beginning of this document, build it with MinGW and link with it or you can simply comment the code in obgrep.cpp main function.

December 21, 2006, at 04:12 PM by Ugo Varetto -
Changed lines 23-25 from:

The compiler is complaining about a missing function; gettimeofday is in fact missing in a MinGW environment.

to:

The compiler is complaining about a missing function; gettimeofday is in fact missing in a MinGW environment.

Changed lines 26-31 from:

1) Open src/babelconfig.h.in 2) Add the followfing declaration:

   void gettimeofday( struct timeval* p, void* );
to:
  1. Open src/babelconfig.h.in
  2. Add the following declaration:
void gettimeofday( struct timeval* p, void* );
Changed lines 32-57 from:

bondtyper.cpp:21: bondtyp.h: No such file or director

The problem is that there are a number of files in the data dir which need to be accessible and they are not because this directory is not in the include path, here is part of the gcc command line you get:

-I. -I. -I. -I../data

To fix this problem you need to add the data dir (where the bondtyp.h resides) to the include path:

3) before running ./configure set the CPPFLAGS evironment variable:

   export CPPFLAGS="-I <absolute path to data dir>"

Now everything compiles but doesn't link yet because there is no definition of function gettimeofday so in case you try to link you get the following error:

 undefined reference to `gettimeofday(timeval*, void* )

We need to write the definition of this function in a c++ file and then modify the makefile to include this new source file.

4) create a file gettimeofday.cpp and add the following code into it:

   (this is a version of some code I found on the internet a while ago)
to:

@[bondtyper.cpp:21: bondtyp.h: No such file or directory@] The problem is that there are a number of files in the data dir which need to be accessible and they are not because this directory is not in the include path, here is part of the gcc command line you get when invoking make: -I. -I. -I. -I../data To fix this problem you need to add the data dir (where the bondtyp.h resides) to the include path:

  1. before running ./configure set the CPPFLAGS evironment variable:

export CPPFLAGS="-I <absolute path to data dir>" Now everything compiles but doesn't link yet because there is no definition of function gettimeofday so in case you try to link you get the following error: undefined reference to `gettimeofday( timeval*, void* ) We need to write the definition of this function in a c++ file and then modify the makefile to include this new source file.

  1. create a file gettimeofday.cpp and add the following code into it:

[@

Changed lines 59-61 from:

5) Modify Makefile.in adding gettimeofday.cpp to the list of source files:

   ...
to:

@]

  1. Modify Makefile.in adding gettimeofday.cpp to the list of source files:

[@ ...

Added lines 71-77:

@] If you build it with the current configuration you will incur in another problem: the dynamic library handler is set to unix

  1. substitute all the instances of dlhandler_unix.xxx in Makefile.in with dlhandler_win32.xxx, there should be a total of five occurrences in the file. The use of a dynamic library handler should be automatically enabled when shared library support is turned on (default).

@in case dlhandler is set to null in Makefile you'll have to manually remove @BUILD_SHARED_TRUE@ in front of am_objects_1 AND dlhandler =dlhandler_win32.cpp you have to do this if you get a link error about an undefined symbol __imp_XXXDLHandler9openFileXXXX

7) if you want to build the executables you'll have to open the cpp files in

   test and tools folder and comment #define USING_OBDLL
Deleted lines 78-93:

If you build it with the current configuration you will incur in another problem: the dynamic library handler is set to unix

6a) substitute all the instances of dlhandler_unix.xxx in Makefile.in with

    dlhandler_win32.xxx, there should be a total of five occurrences in the file.
    The use of a dynamic library handler should be automatically enabled when
    shared library support is turned on (default).

6b) in case dlhandler is set to null in Makefile you'll have to manually remove

    @BUILD_SHARED_TRUE@ in front of am_objects_1 AND dlhandler = dlhandler_win32.cpp
    you have to do this if you get a link error about an undefined
    symbol __imp_XXXDLHandler9openFileXXXX

7) if you want to build the executables you'll have to open the cpp files in

   test and tools folder and comment #define USING_OBDLL
December 21, 2006, at 04:04 PM by Ugo Varetto -
Changed lines 15-18 from:

./configure ... make

 ...
to:

[@ ./configure ... make ...

Changed lines 21-22 from:
to:

@]

December 21, 2006, at 04:00 PM by Ugo Varetto -
Changed lines 6-7 from:

OpenBabel libraries do not seem to be built using the provided VC++ project files neither.

to:

Actually OpenBabel libraries do not seem to be built on Windows using the provided VC++ project files neither.

Changed lines 15-16 from:

./configure

to:

./configure ... make

Deleted lines 18-19:

make

 ...
Changed lines 20-21 from:


to:
December 21, 2006, at 03:59 PM by Ugo Varetto -
Changed lines 1-2 from:
to:

Update in progress

December 21, 2006, at 03:58 PM by Ugo Varetto -
Added line 1:
Changed lines 12-14 from:

If you try to build OpenBabel 2.0.2 on Windows with MinGW you should get something similar to the following:

to:

If you try to build OpenBabel 2.0.2 on Windows with MinGW you should get something similar to the following:

Changed lines 20-21 from:
to:


December 21, 2006, at 03:57 PM by Ugo Varetto -
Added lines 1-114:

OpenBabel and MinGW

OpenBabel doesn't build out of the box with MinGW, this section describes how to build OpenBabel 2.0.2 on Windows with MinGW. OpenBabel libraries do not seem to be built using the provided VC++ project files neither.

Following the instructions on this page you'll be able to build all the libraries and tools except for obgrep which has a dependency on a library which is not included in the OpenBabel distribution: XGetopt and that you can download from here: http://www.codeproject.com/cpp/xgetopt.asp?df=100.

OpenBabel requires libxml2 so make sure you have this library properly installed in your MinGW environment; libxml can be found here: http://xmlsoft.org

If you try to build OpenBabel 2.0.2 on Windows with MinGW you should get something similar to the following:

./configure

 ...

make

 ...

../../src/obutil.h:73: error: `gettimeofday' undeclared (first use this function)

The compiler is complaining about a missing function; gettimeofday is in fact missing in a MinGW environment.

To fix this you can do the following:

1) Open src/babelconfig.h.in 2) Add the followfing declaration:

   void gettimeofday( struct timeval* p, void* );

If you build now you get a brand new error message:

bondtyper.cpp:21: bondtyp.h: No such file or director

The problem is that there are a number of files in the data dir which need to be accessible and they are not because this directory is not in the include path, here is part of the gcc command line you get:

-I. -I. -I. -I../data

To fix this problem you need to add the data dir (where the bondtyp.h resides) to the include path:

3) before running ./configure set the CPPFLAGS evironment variable:

   export CPPFLAGS="-I <absolute path to data dir>"

Now everything compiles but doesn't link yet because there is no definition of function gettimeofday so in case you try to link you get the following error:

 undefined reference to `gettimeofday(timeval*, void* )

We need to write the definition of this function in a c++ file and then modify the makefile to include this new source file.

4) create a file gettimeofday.cpp and add the following code into it:

   (this is a version of some code I found on the internet a while ago)
   #include <windows.h>
   #include <sys/time.h>

   void __stdcall GetSystemTimeAsFileTime(FILETIME*);

   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);
   }

5) Modify Makefile.in adding gettimeofday.cpp to the list of source files:

   ...
   @BUILD_SHARED_TRUE@ fingerprints/libfingerprints.la @LTLIBOBJS@
   am__libopenbabel_la_SOURCES_DIST = gettimeofday.cpp atom.cpp base.cpp bitvec.cpp    ...
   @BUILD_SHARED_TRUE@am__objects_1 = dlhandler_unix.lo
   am_libopenbabel_la_OBJECTS = gettimeofday.lo base.lo bitvec.lo bond.lo    ...
   libopenbabel_la_SOURCES = 		gettimeofday.cpp atom.cpp base.cpp bitvec.cpp bond.cpp    ...

If you build it with the current configuration you will incur in another problem: the dynamic library handler is set to unix

6a) substitute all the instances of dlhandler_unix.xxx in Makefile.in with

    dlhandler_win32.xxx, there should be a total of five occurrences in the file.
    The use of a dynamic library handler should be automatically enabled when
    shared library support is turned on (default).

6b) in case dlhandler is set to null in Makefile you'll have to manually remove

    @BUILD_SHARED_TRUE@ in front of am_objects_1 AND dlhandler = dlhandler_win32.cpp
    you have to do this if you get a link error about an undefined
    symbol __imp_XXXDLHandler9openFileXXXX

7) if you want to build the executables you'll have to open the cpp files in

   test and tools folder and comment #define USING_OBDLL

   // used to set import/export for Cygwin DLLs
   #ifdef WIN32
   //#define USING_OBDLL
   #endif

8) run configure --prefix=<installation folder> then make: this will build the

   libraries into src/.libs, and the executables in the src, tools and test folders.
   You can then run make install.
   Note that to have make install succeed you have to also fix obgrep.cpp so that it
   can somehow build: either you get the XGetopt library mentioned at the beginning
   of this document, build it with MinGW and link with it or you can simply comment
   the code in obgrep.cpp main function.