Difference between revisions of "Install (MinGW)"
Baoilleach (Talk | contribs) m (win32 not windows) |
m |
||
Line 12: | Line 12: | ||
<pre> | <pre> | ||
− | + | sh configure | |
... | ... | ||
make | make |
Revision as of 06:44, 12 February 2007
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:
sh 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:
...
@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
7a) 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).
7b) 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 in Makefile.in
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