Developer:Building

From Open Babel
Jump to: navigation, search

In all cases, if you have questions about the building/compiling process for Open Babel, please contact the developer list at [email protected]

UNIX/Linux/Mac OS X

The build environment on UNIX-like platforms, including Linux, and Mac OS X involves a variety of tools.

  • autoconf - Used to detect headers, libraries, and other packages to flexibly build on a range of platforms
  • automake - Used to create the "Makefile.in" and "Makefile" build rules
  • libtool - Used to build shared libraries (i.e., libopenbabel) and the shared object modules for file translators

Because these are not always present on every system (often "devel" packages or other developer tools are needed), the build setup is designed to compile the existing source and NOT rebuild the build system itself (i.e., the configure script, babelconfig.h, and the Makefile scripts).

If you intend to add source code files, you should make sure to also edit the build files -- particularly the Makefile.am files used by automake. You will also need to re-run the configure script, e.g.

 ./configure --enable-maintainer-mode

The --enable-maintainer-mode option adds the rules to rebuild Makefiles and other elements of the build environment when changed.

The configure script itself is generated from configure.in by autoconf. It rarely needs changes, except when needed to detect the presence of new libraries on a system. If you think you need to make changes to the configure script, please send an e-mail on the developer list and someone will be glad to point you in the right directions.

By default on UNIX-like platforms (including Cygwin, Mac OS X, Linux, etc.) all code is built for shared libraries. There are, however, a few differences, particularly with Cygwin.

Build Outputs (Linux, Unix, Mac OS X)

  • src/math/libmath -- Temporary build library (linked into libopenbabel)
  • src/formats/inchi -- libinchi library for InChI output -- built if not found among the system libraries
  • src/formats/ -- Individual shared, loadable file format modules/plugins for each file format
  • src/libopenbabel -- Main shared library, including OBConversion, OBError, OBMol, etc.
  • src/babel -- Main command-line binary
  • tools/ -- A variety of other command-line binaries including obgrep, obchiral, obprop, etc.
  • test/roundtrip -- A testing tool for comparing the chemical equivalence of two files produced during conversion from babel
  • test/ -- A set of unit tests

Build Outputs (Cygwin)

On Cygwin, the current build environment has difficulty producing individual file translation shared objects. Therefore, the configure script and Makefiles build "libformats" which is a temporary build library, linked into libopenbabel itself. All shared libraries (i.e., libopenbabel) produce DLLs.

  • src/math/libmath -- Temporary build library (linked into libopenbabel)
  • src/formats/inchi -- libinchi library for InChI output -- built if not found among the system libraries
  • src/formats/libformat -- Temporary build library including every file format (linked into libopenbabel)
  • src/libopenbabel.dll -- Main shared library, including OBConversion, OBError, OBMol, etc.
  • src/babel -- Main command-line binary
  • tools/ -- A variety of other command-line binaries including obgrep, obchiral, obprop, etc.
  • test/roundtrip -- A testing tool for comparing the chemical equivalence of two files produced during conversion from babel
  • test/ -- A set of unit tests

Windows (Visual C++)

The SVN and source distributions should include Visual C++ project files. These are used to compile the Windows GUI.

Perl and Python Bindings

The Perl and Python language bindings for the Open Babel library are generated using a tool called SWIG:

  • swig - Simplified Wrapper and Interface Generator

These files are auto-generated from the SWIG file "openbabel.i" by the UNIX Makefiles, assuming SWIG is detected by the configure script and --enable-maintainer-mode is used.

Perl

The Perl bindings are not built by default on either UNIX or Windows systems. It currently uses the ExtUtils::MakeMaker build system.

It currently assumes a UNIX-like build environment and searches through common paths for libopenbabel and header files.

perl Makefile.PL
make
make test
make install

Python

The Python bindings are not build by default on any system either. They currently use the Python distutils build system.

It currently assumes a UNIX-like build environment and searches through common paths for libopenbabel and header files. It also looks for the environment variable OPENBABEL_INSTALL as the base path for the installation of Open Babel (e.g., /usr/local, /opt, /usr, /home/foobar, etc.)

python setup.py build
python setup.py install