Difference between revisions of "Install (MinGW)"

From Open Babel
Jump to: navigation, search
Line 1: Line 1:
 
This document contains instructions for building OpenBabel (OB) on Windows with [http://www.mingw.org/ 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 [http://www.cygwin.com/ Cygwin].
 
This document contains instructions for building OpenBabel (OB) on Windows with [http://www.mingw.org/ 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 [http://www.cygwin.com/ Cygwin].
  
Date: March 31, 2009, Andreas Maunz. Tested with OB 2.1.1 on Windows Vista.
+
Date: March 31, 2009, Andreas Maunz. Tested with OB 2.1.1 and 2.2.1 on Windows Vista.
  
 
== Preliminaries: ==
 
== Preliminaries: ==
OpenBabel requires libxml2 so make sure you have this library properly installed in your MinGW environment; libxml can be found [http://xmlsoft.org/, 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:
+
OB requires libxml2; libxml can be found [http://xmlsoft.org/, 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:
 
<pre>
 
<pre>
 
     --cflags)
 
     --cflags)
Line 15: Line 15:
 
</pre>
 
</pre>
  
[http://www.mingw.org/wiki/Getting_Started Install] current Msys and MinGW version.  
+
OB requires zlib; zlib can be found [http://gnuwin32.sourceforge.net/packages/zlib.htm here]. Make sure OB can find the header files and DLL during configuration by prior adding the respective directories to your $PATH environment variable.
  
<!--[http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=241304 Update] to the latest version of g++ for MinGW (g++-sjlj, see also the [http://downloads.sourceforge.net/mingw/gcc-4.2.1-sjlj-2-release_notes.txt?use_mirror=freefr release notes]). Unpack gcc-g++-4.2.1-sjlj-2.tar.gz and gcc-core-4.2.1-sjlj-2.tar.gz in your MinGW root directory-->
+
[http://www.mingw.org/wiki/Getting_Started 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.
Unpack OB source, start Msys and change to OB directory.  
+
  
== Build OB: ==
+
== Build OB 2.1.1: ==
<!--./configure --without-boost --disable-dynamic-modules CXX=g++-sjlj-->
+
 
<pre>
 
<pre>
 
./configure
 
./configure
Line 53: Line 51:
 
make install
 
make install
 
</pre>
 
</pre>
 +
 +
== Build OB 2.2.1: ==
 +
[http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=241304 Update] the g++ compiler to version 4 (g++-sjlj, see also the [http://downloads.sourceforge.net/mingw/gcc-4.2.1-sjlj-2-release_notes.txt?use_mirror=freefr release notes]). Unpack gcc-g++-4.2.1-sjlj-2.tar.gz and gcc-core-4.2.1-sjlj-2.tar.gz in your MinGW root directory
 +
 +
<pre>
 +
./configure
 +
</pre>
 +
You may want to leave out boost and/or loading of dynamic modules: <code>./configure --without-boost --disable-dynamic-modules</code>.
 +
<pre>
 +
make
 +
</pre>
 +
Although compilation of babel.exe breaks, libopenbabel-3.dll is generated.
  
 
[[Category:Installation]]
 
[[Category:Installation]]
 
--[[User:Amaunz|Amaunz]] 07:18, 31 March 2009 (PDT)
 
--[[User:Amaunz|Amaunz]] 07:18, 31 March 2009 (PDT)

Revision as of 07:06, 2 April 2009

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, Andreas Maunz. Tested with OB 2.1.1 and 2.2.1 on Windows Vista.

Preliminaries:

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

and

    --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:

./configure

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

with

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:

Update the g++ compiler to version 4 (g++-sjlj, see also the release notes). Unpack gcc-g++-4.2.1-sjlj-2.tar.gz and gcc-core-4.2.1-sjlj-2.tar.gz in your MinGW root directory

./configure

You may want to leave out boost and/or loading of dynamic modules: ./configure --without-boost --disable-dynamic-modules.

make

Although compilation of babel.exe breaks, libopenbabel-3.dll is generated. --Amaunz 07:18, 31 March 2009 (PDT)