Difference between revisions of "Install (MinGW)"

From Open Babel
Jump to: navigation, search
 
Line 3: Line 3:
 
This text was contributed by the [http://www.cscs.ch/molekel/ Molekel] project. In the future, it is intended that Open Babel will compile cleanly on MinGW cleanly.
 
This text was contributed by the [http://www.cscs.ch/molekel/ Molekel] project. In the future, it is intended that Open Babel will compile cleanly on MinGW cleanly.
  
Using these instructions you'll be able to build and install libraries,
+
Using these instructions you'll be able to build and install libraries, includes, babel.exe and all the tests except unitcell.exe and smarttest.exe.
includes, babel.exe and all the tests except unitcell.exe and smarttest.exe.
+
  
0) OpenBabel requires libxml2 so make sure you have this library properly
+
0) OpenBabel requires libxml2 so make sure you have this library properly installed in your MinGW environment; libxml can be found here:
  installed in your MinGW environment; libxml can be found here:
+
 
   http://xmlsoft.org/
 
   http://xmlsoft.org/
  
Line 13: Line 11:
 
get something similar to the following:
 
get something similar to the following:
  
 +
<pre>
 
./configure
 
./configure
 
  ...
 
  ...
Line 19: Line 18:
 
../../src/obutil.h:73: error: `gettimeofday' undeclared (first use
 
../../src/obutil.h:73: error: `gettimeofday' undeclared (first use
 
this function)
 
this function)
 +
</pre>
  
The compiler is complaining about a missing function; gettimeofday is in fact
+
The compiler is complaining about a missing function; gettimeofday is in fact missing in a MinGW environment.
missing in a MinGW environment.
+
  
 
To fix this you can do the following:
 
To fix this you can do the following:
Line 31: Line 30:
 
If you build now you get a brand new error message:
 
If you build now you get a brand new error message:
  
bondtyper.cpp:21: bondtyp.h: No such file or director
+
  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
 
The problem is that there are a number of files in the data dir which need
Line 37: Line 36:
 
path, here is part of the gcc command line you get:
 
path, here is part of the gcc command line you get:
  
-I. -I. -I. -I../data
+
  -I. -I. -I. -I../data
  
 
To fix this problem you need to add the data dir (where the bondtyp.h resides)
 
To fix this problem you need to add the data dir (where the bondtyp.h resides)
Line 49: Line 48:
 
error:
 
error:
  
undefined reference to `gettimeofday(timeval*, void* )
+
  undefined reference to `gettimeofday(timeval*, void* )
  
 
We need to write the definition of this function in a c++ file and then
 
We need to write the definition of this function in a c++ file and then
Line 56: Line 55:
 
5) create a file gettimeofday.cpp and add the following code into it:
 
5) 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)
 
   (this is a version of some code I found on the internet a while ago)
 +
 
 +
<pre>
 
   #include <windows.h>
 
   #include <windows.h>
 
   #include <sys/time.h>
 
   #include <sys/time.h>
Line 72: Line 73:
 
       p->tv_sec= (long)((now.ns100-(116444736000000000LL))/10000000LL);
 
       p->tv_sec= (long)((now.ns100-(116444736000000000LL))/10000000LL);
 
   }
 
   }
 +
</pre>
  
 
6) Modify Makefile.in adding gettimeofday.cpp to the list of source files:
 
6) Modify Makefile.in adding gettimeofday.cpp to the list of source files:
 
   ...
 
   ...
 +
<pre>
 
   @[email protected] fingerprints/libfingerprints.la @[email protected]
 
   @[email protected] fingerprints/libfingerprints.la @[email protected]
 
   am__libopenbabel_la_SOURCES_DIST = gettimeofday.cpp atom.cpp
 
   am__libopenbabel_la_SOURCES_DIST = gettimeofday.cpp atom.cpp
Line 85: Line 88:
 
                 gettimeofday.cpp atom.cpp base.cpp bitvec.cpp bond.cpp \
 
                 gettimeofday.cpp atom.cpp base.cpp bitvec.cpp bond.cpp \
 
   ...
 
   ...
 +
</pre>
  
 
If you build it with the current configuration you will incur in another
 
If you build it with the current configuration you will incur in another
Line 104: Line 108:
 
   installing for example into /c/local/test creates the following dir tree:
 
   installing for example into /c/local/test creates the following dir tree:
  
 +
<pre>
 
/c/local/test:
 
/c/local/test:
 
bin
 
bin
Line 190: Line 195:
 
torlib.txt
 
torlib.txt
 
types.txt
 
types.txt
 +
</pre>
  
 
[[Category:Installation]]
 
[[Category:Installation]]

Revision as of 14:44, 16 November 2006

This is a description of how to build openbabel 2.0.x on Windows with MinGW, if you do not care about what's going on and why the following actions are required just go through the numbered list items (1 to 8) and skip the explanations.

This text was contributed by the Molekel project. In the future, it is intended that Open Babel will compile cleanly on MinGW cleanly.

Using these instructions you'll be able to build and install libraries, includes, babel.exe and all the tests except unitcell.exe and smarttest.exe.

0) 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.1 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:

4) 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.

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

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

  ...
   @[email protected] fingerprints/libfingerprints.la @[email protected]
   am__libopenbabel_la_SOURCES_DIST = gettimeofday.cpp atom.cpp
base.cpp bitvec.cpp \
   ...
   @[email protected]__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

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

   dlhandler_windows.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).

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

   @[email protected] in front of am_objects_1 and dlhandler =

dlhandler_win32.cpp


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

  libraries into src/.libs, you can then run make install
  installing for example into /c/local/test creates the following dir tree:
/c/local/test:
bin
include
lib
share

/c/local/test/bin:
babel.exe
libinchi-0.dll
libopenbabel-1.dll

/c/local/test/include:
inchi
openbabel-2.0

/c/local/test/include/inchi:
inchi_api.h

/c/local/test/include/openbabel-2.0:
openbabel

/c/local/test/include/openbabel-2.0/openbabel:
babelconfig.h
base.h
bitvec.h
bondtyper.h
chains.h
chiral.h
data.h
dlhandler.h
fingerprint.h
generic.h
grid.h
inchi_api.h
math
matrix.h
mol.h
molchrg.h
obconversion.h
oberror.h
obiter.h
obmolecformat.h
obutil.h
parsmart.h
patty.h
phmodel.h
reaction.h
ring.h
rotamer.h
rotor.h
typer.h

/c/local/test/include/openbabel-2.0/openbabel/math:
matrix3x3.h
vector3.h

/c/local/test/lib:
libinchi.a
libinchi.dll.a
libinchi.la
libopenbabel.a
libopenbabel.dll.a
libopenbabel.la
openbabel

/c/local/test/lib/openbabel:

/c/local/test/share:
openbabel

/c/local/test/share/openbabel:
2.0.1

/c/local/test/share/openbabel/2.0.1:
SMARTS_InteLigand.txt
aromatic.txt
atomtyp.txt
bondtyp.txt
element.txt
isotope-small.txt
isotope.txt
patterns.txt
phmodel.txt
resdata.txt
torlib.txt
types.txt