Difference between revisions of "Install (source code)"

From Open Babel
Jump to: navigation, search
m
(Initial attempt to update instructures...not sure if have time for more today)
Line 1: Line 1:
 
== Introduction and requirements ==
 
== Introduction and requirements ==
  
Here we describe the compilation and installation procedure for OpenBabel 2.2.3. For a different release, the version number will be different and you should take this in account when reading the instructions below.  
+
Here we describe the compilation and installation procedure for OpenBabel 2.3.0 or newer. For information on installing Open Babel 2.2 series, see [[Install Open Babel 2.2]].  
  
The following are required to compile Open Babel:
+
The following are '''required''' to compile Open Babel:
 
:: The latest version of the [http://sourceforge.net/project/showfiles.php?group_id=40728&package_id=32894 Open Babel source code]
 
:: The latest version of the [http://sourceforge.net/project/showfiles.php?group_id=40728&package_id=32894 Open Babel source code]
:: A C++ compiler (like g++)
+
:: A '''C++ compiler''' (like GNU g++ or Intel Compiler icc)
 
:: A makefile system (like GNU make)
 
:: A makefile system (like GNU make)
 +
:: '''CMake 2.4''' or newer (available as the ''cmake'' package in Ubuntu, or from the [http://cmake.org/cmake/resources/software.html CMake website])
  
The following are optional when compiling Open Babel, but if not installed, fewer features will be available:
+
The following are '''optional''' when compiling Open Babel, but if not installed, fewer features will be available:
:: libxml2 development headers are required to read/write CML files (the libxml2-dev package in Ubuntu)
+
:: '''libxml2''' development headers are required to read/write CML files (the ''libxml2-dev'' package in Ubuntu)
:: zlib.h is required to support reading gzipped files (the zlib1g-dev package in Ubuntu)
+
:: '''zlib.h''' is required to support reading gzipped files (the ''zlib1g-dev'' package in Ubuntu)
 
:: If using GCC 3.x to compile (and not GCC 4.x), then the Boost headers are required for certain formats (CML, Chemkin, Chemdraw CDX, MDL RXN and RSMI)
 
:: If using GCC 3.x to compile (and not GCC 4.x), then the Boost headers are required for certain formats (CML, Chemkin, Chemdraw CDX, MDL RXN and RSMI)
 +
:: '''Eigen''' version 2 is required for some API classes (OBAlign, OBConformerSearch) and plugins (the QEq and QTPIE charge models, the conformer operation). These will not be available otherwise.
 +
::: Eigen may be available through your package manager (the ''libeigen2-dev'' package in Ubuntu). Alternatively, Eigen is available from http://eigen.tuxfamily.org. It doesn’t need to be compiled or installed. Just unzip it and specify its location when configuring cmake (see below) using ''-DEIGEN2_INCLUDE_DIR=whereever''.
 +
 +
If you want to build the '''GUI''' (Graphical User Interface), you need the following:
 +
:: wxWidgets 2.8 (or newer)
 +
:::: Binary packages may be available through your package manager (''wx-common'' and ''wx2.8-headers'' on Ubuntu) or from http://www.wxwidgets.org/downloads/. Otherwise, you could try compiling it yourself from the source code.
  
 
If you are interested in using OpenBabel from a scripting language, then the following notes apply:
 
If you are interested in using OpenBabel from a scripting language, then the following notes apply:
Line 22: Line 29:
 
== Installing globally with root access ==
 
== Installing globally with root access ==
  
(A1) Open a command window, and
+
(A1) Open a command window, and decompress the downloaded file with the following command:
decompress the downloaded file with following command:
+
  
 
<pre>
 
<pre>
tar zxvf openbabel-2.0.2.tar.gz
+
tar zxvf openbabel-2.3.0.tar.gz
 
</pre>
 
</pre>
  
This will create a folder called 'openbabel-2.0.2'.
+
This will create a folder called 'openbabel-2.3.0' containing the Open Babel source code.
 +
 
 +
The recommended way of building Open Babel is to use separate source and build folders. Let's call them ''ob-src'' and ''ob-build'':
 +
 
 +
<pre>
 +
mv openbabel-2.3.0 ob-src
 +
mkdir ob-build
 +
</pre>
  
 
(A2) You now need to configure and compile openbabel. To do this, change
 
(A2) You now need to configure and compile openbabel. To do this, change
directory into 'openbabel-2.0.2'. Run the following commands, one after
+
directory into ''ob-src''. Run the following commands, one after
 
the other
 
the other
  
 
<pre>
 
<pre>
./configure 2>&1 | tee configure.out
+
cmake ../ob-src 2>&1 | tee cmake.out
 
make 2>&1 | tee make.out
 
make 2>&1 | tee make.out
 
</pre>
 
</pre>
  
If you get an error message about "__builtin_popcount undeclared", replace src/fingerprint.cpp by [http://openbabel.svn.sourceforge.net/viewvc/openbabel/openbabel/branches/openbabel-2-2-x/src/fingerprint.cpp?revision=2707&pathrev=2707 this file] and include/openbabel/fingerprint.h by [http://openbabel.svn.sourceforge.net/viewvc/openbabel/openbabel/branches/openbabel-2-2-x/include/openbabel/fingerprint.h?revision=2707&pathrev=2707 this file], and run 'make' again.
+
If there are any errors at this point, send an email to the [mailto:openbabel[email protected].sourceforge.net openbabel-discuss] mailing list and attach the files 'cmake.out' and 'make.out'.
  
If there are any other errors at this point, send an email to the [mailto:[email protected] openbabel-discuss] mailing list and attach the files 'configure.out' and 'make.out'.
+
If you look at the output of 'cmake' you can see whether CML and gzip support will be included in Open Babel (see Optional Libraries above).
 
+
<pre>#FIXME - INSERT EXAMPLE HERE</pre>
If you look at the output of 'configure' you can see whether CML and gzip support will be included in openbabel (see Optional Libraries above).
+
<pre>
+
...
+
checking for libxml - version >= 2.6.5...yes (version 2.6.21)
+
...
+
checking for zlib.h... yes
+
</pre>
+
  
 
(A3) If you have root permissions, you can install openbabel globally.
 
(A3) If you have root permissions, you can install openbabel globally.
Line 57: Line 63:
 
make install
 
make install
 
</pre>
 
</pre>
Note: This will take about 5 minutes, and will display a large amount of output on the screen.
 
  
(A4) If necessary (e.g. babel doesn't work), add the location of the installed libopenbabel.so to the LD_LIBRARY_PATH, in my case:
+
(A4) If necessary (e.g. '''babel''' doesn't work), add the location of the installed libopenbabel.so to the LD_LIBRARY_PATH, in my case:
 
<pre>
 
<pre>
 
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
 
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

Revision as of 03:51, 25 October 2010

Introduction and requirements

Here we describe the compilation and installation procedure for OpenBabel 2.3.0 or newer. For information on installing Open Babel 2.2 series, see Install Open Babel 2.2.

The following are required to compile Open Babel:

The latest version of the Open Babel source code
A C++ compiler (like GNU g++ or Intel Compiler icc)
A makefile system (like GNU make)
CMake 2.4 or newer (available as the cmake package in Ubuntu, or from the CMake website)

The following are optional when compiling Open Babel, but if not installed, fewer features will be available:

libxml2 development headers are required to read/write CML files (the libxml2-dev package in Ubuntu)
zlib.h is required to support reading gzipped files (the zlib1g-dev package in Ubuntu)
If using GCC 3.x to compile (and not GCC 4.x), then the Boost headers are required for certain formats (CML, Chemkin, Chemdraw CDX, MDL RXN and RSMI)
Eigen version 2 is required for some API classes (OBAlign, OBConformerSearch) and plugins (the QEq and QTPIE charge models, the conformer operation). These will not be available otherwise.
Eigen may be available through your package manager (the libeigen2-dev package in Ubuntu). Alternatively, Eigen is available from http://eigen.tuxfamily.org. It doesn’t need to be compiled or installed. Just unzip it and specify its location when configuring cmake (see below) using -DEIGEN2_INCLUDE_DIR=whereever.

If you want to build the GUI (Graphical User Interface), you need the following:

wxWidgets 2.8 (or newer)
Binary packages may be available through your package manager (wx-common and wx2.8-headers on Ubuntu) or from http://www.wxwidgets.org/downloads/. Otherwise, you could try compiling it yourself from the source code.

If you are interested in using OpenBabel from a scripting language, then the following notes apply:

Python is required to compile the Python bindings
Perl is required to compile the Perl bindings
If you are compiling directly from the Subversion repository, then you need to create the Python/Perl bindings yourself. To do so you need to install the latest version of SWIG (at the time of writing, 1.3.40, but there may be a new version).

If you want to install globally on your system, you will need root access, and should follow these instructions. If you don't have root access or if you simply wish to install in your 'home' area, see Installing locally without root access.

Installing globally with root access

(A1) Open a command window, and decompress the downloaded file with the following command:

tar zxvf openbabel-2.3.0.tar.gz

This will create a folder called 'openbabel-2.3.0' containing the Open Babel source code.

The recommended way of building Open Babel is to use separate source and build folders. Let's call them ob-src and ob-build:

mv openbabel-2.3.0 ob-src
mkdir ob-build

(A2) You now need to configure and compile openbabel. To do this, change directory into ob-src. Run the following commands, one after the other

cmake ../ob-src 2>&1 | tee cmake.out
make 2>&1 | tee make.out

If there are any errors at this point, send an email to the openbabel-discuss mailing list and attach the files 'cmake.out' and 'make.out'.

If you look at the output of 'cmake' you can see whether CML and gzip support will be included in Open Babel (see Optional Libraries above).

#FIXME - INSERT EXAMPLE HERE

(A3) If you have root permissions, you can install openbabel globally. As root, run the following command:

make install

(A4) If necessary (e.g. babel doesn't work), add the location of the installed libopenbabel.so to the LD_LIBRARY_PATH, in my case:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib


Installing locally without root access

If you don't have root access, you can still compile and use Open Babel.

(B1) Follow Step A1 above

(B2) Make a local directory to install everything into. In this example, I will use the folder "tree" in my home directory:

mkdir /home/noel/tree

(B3) Instead of Step A2 above, use the 'prefix' option of configure as follows:

./configure --prefix=/home/noel/tree 2>&1 | tee configure.out
make 2>&1 | tee make.out

(B4) You can now install without root permissions using the following command:

make install

Note: This will take about 5 minutes, and will display a large amount of output on the screen.

This installs the babel executable (and related tools) to /home/noel/tree/bin so you need to add this directory to your PATH in your startup scripts (that is, .bashrc, or whatever):

export PATH=$PATH:/home/noel/tree/bin

(B5) Add the location of the installed libopenbabel.so to the LD_LIBRARY_PATH, in my case:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/noel/tree/lib

Compile bindings for Java, .NET, Perl, Python or Ruby

To compile and install the bindings for the various languages supported, please see the appropriate page for Java, .NET, Perl, Python, Ruby.

Compile the development code

For information on compiling our development code, please see the CMake page.