This document contains instructions for building OpenBabel (OB) on Windows with MinGW. The resulting DLL (libopenbabel-3.dll) may be linked directly from Windows applications compiled with MinGW, so there is no need to deal with (import) libraries created with Microsoft Visual C++. This is especially useful if your existing software uses a GNU make based build system. Binaries created with MinGW are native and do not need an emulation layer, such as Cygwin.
Date: March 31, 2009, Tested with OB 2.1.1 and 2.2.1 on Windows Vista.
OB requires libxml2; libxml can be found here. Specifically, this requires you to edit the xml2-config script. I recommend you directly link a test application against libxml2.dll and insert the respective -I and -L flags into xml2-config. The relevant section of mine looks like this:
--cflags) echo -I/home/libxml2-2.7.3.win32/include/libxml -I/home/libxml2-2.7.3.win32/include
--libs) echo /c/Windows/System32/libxml2.dll -liconv -lm -Wl,-s -lwsock32 -liberty
OB requires zlib; zlib can be found here. Make sure OB can find the header files and DLL during configuration by prior adding the respective directories to your $PATH environment variable.
Install current Msys and MinGW version. Unpack OB source, start Msys and change to OB directory. Warning: I experienced "object name conflicts" during compilation when the $PATH contained the windows\system32 directory at the beginning.
Build OB 2.1.1:
You may want to leave out boost and/or loading of dynamic modules:
./configure --without-boost --disable-dynamic-modules.
cd src/formats/inchi make cd ../../../tools
Edit the Makefile and exchange the following lines
babel_DEPENDENCIES = ../src/libopenbabel.la babel_LDADD = ../src/libopenbabel.la
babel_DEPENDENCIES = ../src/libopenbabel.la $(formats_objects) babel_LDADD = ../src/libopenbabel.la $(formats_objects)
Repeat the editing for the rest of the executables if you need more than babel.exe. Then continue to build and install OB. The tools as well as the DLL will be placed in /local/bin (C:\Msys\local\bin).
cd .. make make install
Build OB 2.2.1:
You may want to leave out boost and/or loading of dynamic modules by adding this to the configure command:
Compilation of libopenbabel-3.dll breaks due to missing zlib support. You may manually fix this by repeating the last failed command and adding the file path to
--Amaunz 07:18, 31 March 2009 (PDT)
Build OB 2.2.2 (svn: branches/openbabel-2-2-x -- 7 July 2009)
Install MinGW with gcc 4. I used the manual install since the automated installer only allowed me to install gcc 3.4. Regardless of the install method, make sure to have at least these packages installed (i.e. extracted) to C:/MinGW
- MinGW Runtime (mingwrt-3.15.2-mingw32-dev.tar.gz)
- Windows 32 API (w32api-3.13-mingw32-dev-tar.gz)
- GNU Binutils (binutils-2.19.1-mingw32-bin.tar.gz)
- GCC 4 (gcc-core-4.4.0-mingw32-bin.tar.gz, gcc-core-4.4.0-mingw-dll.tar.gz, gcc-g++-4.4.0-mingw32-bin.tar.gz,
gcc-g++-4.4.0-mingw32-dll.tar.gz, gmp-4.2.4-mingw32-dll.tar.gzi, mpfr-2.4.1-mingw32-dll.tar.gz)
Install MSYS using the installer (MSYS-1.0.10.exe). Start the msys prompt using Start > Programs > MinGW > MSYS > msys and verify the g++ version.
$ g++ -v ... gcc version 4.4.0 (GCC)
It is also possible to use the automated installer and only add the g++ 4.4 packages later. See the [MinGW Website] for more information.
- work in your MinGW home directory. I tried to build from a /z/... drive and didn't have much success this way.
- Using MinGW, make sure to link directly to the dll files
Building OpenBabel using CMake 2.6
Install CMake 2.6, an installer for the latest version is available on the [CMake Website]
$ export PATH=$PATH:/c/Program\ Files/CMake\ 2.6/bin $ cd ~/openbabel-2-2-x $ mkdir build $ cd build $ cmake -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX=install_dir -DZLIB_INCLUDE_DIR=../include -DZLIB_LIBRARY=../windows-vc2005/zlib1.dll -DLIBXML2_INCLUDE_DIR=../include -DLIBXML2_LIBRARIES=../windows-vc2005/libxml2.dll .. $ make $ make install
All files should now be installed to ~/openbabel-2-2-x/build/install_dir. However, you still need to copy zlib1.dll, iconv.dll & libxml2.dll to .../install_dir/bin.
$ cp ../windows-vc2005/zlib1.dll install_dir/bin $ cp ../windows-vc2005/libxml2.dll install_dir/bin $ cp ../windows-vc2005/iconv.dll install_dir/bin $ export PATH=$PATH:install_dir/bin $ babel -H ...