Difference between revisions of "Install (source code)"

From Open Babel
Jump to: navigation, search
(MACOSX_DEPLOYMENT_TARGET info)
(Installing globally with root access)
 
(29 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
== Introduction and requirements ==
 
== Introduction and requirements ==
  
Here we describe the compilation and installation procedure for OpenBabel 2.0.2. 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&release_id=434410 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, it may restrict the features available:
+
The following are '''optional''' when compiling Open Babel, but if not installed, fewer features will be available:
:: Python is required to compile the Python bindings
+
:: '''libxml2''' development headers are required to read/write CML files (the ''libxml2-dev'' package in Ubuntu)
:: Perl is required to compile the Perl bindings
+
:: '''zlib.h''' is required to support reading gzipped files (the ''zlib1g-dev'' package in Ubuntu)
:: SWIG is required to recreate the Python/Perl bindings (this is only necessary for developers...see [[Install (source code)#Advanced Notes | Advanced Notes]] for more info)
+
:: 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)
:: libxml2 development headers are required to read/write CML files (the libxml2-dev package in Ubuntu)
+
:: '''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.
:: zlib.h is required to support reading gzipped files (the zlib1g-dev package in Ubuntu)
+
::: 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 want to use Open Babel using one of the supported '''language bindings''', then the following notes may apply:
 +
:: You need the the Python development libraries to compile the Python bindings (package ''python-dev'' in Ubuntu)
 +
:: You need the the Perl development libraries to compile the Perl bindings (package ''libperl-dev'' in Ubuntu)
 +
:: ''Developer note'': 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, 2.0.1, but there may be a new version).
  
 
If you want to install globally on your system, you will need root access, and should follow [[Install (source code)#Installing globally with root access | these instructions]]. If you don't have root access or if you simply wish to install in your 'home' area, see [[Install (source code)#Installing locally without root access | Installing locally without root access]].
 
If you want to install globally on your system, you will need root access, and should follow [[Install (source code)#Installing globally with root access | these instructions]]. If you don't have root access or if you simply wish to install in your 'home' area, see [[Install (source code)#Installing locally without root access | Installing locally without root access]].
Line 19: 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.
  
(A2) You now need to configure and compile openbabel. To do this, change
+
The recommended way of building Open Babel is to use separate source and build folders. Let's call them ''ob-src'' and ''ob-build'':
directory into 'openbabel-2.0.2'. Run the following commands, one after
+
the other
+
  
 
<pre>
 
<pre>
./configure | tee configure.out
+
mv openbabel-2.3.0 ob-src
make | tee make.out
+
mkdir ob-build
 
</pre>
 
</pre>
  
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 'configure.out' and 'make.out'.
+
(A2) You now need to configure and compile openbabel. To do this, change
 
+
directory into ''ob-src''. Run the following commands, one after
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).
+
the other:
 
<pre>
 
<pre>
...
+
cd ob-build
checking for libxml - version >= 2.6.5...yes (version 2.6.21)
+
cmake ../ob-src 2>&1 | tee cmake.out
...
+
make 2>&1 | tee make.out
checking for zlib.h... yes
+
 
</pre>
 
</pre>
  
(A3) If you have root permissions, you can install openbabel globally.
+
If there are any errors at this point, send an email to the [mailto:openbabel[email protected] openbabel-discuss] mailing list and attach the files ''cmake.out'' and ''make.out''.
As root, run the following command:
+
 
 +
If you look at the output of CMake you can see whether CML and gzip support will be included in Open Babel (see the optional dependencies above).
 +
<pre>#FIXME - INSERT EXAMPLE HERE</pre>
  
 +
(A3) If you have root permissions, you can install Open Babel globally.
 +
As root, run the following command:
 
<pre>
 
<pre>
 
make install
 
make install
 
</pre>
 
</pre>
  
==== Install the Python bindings globally ====
+
(A4) If necessary (e.g. ''obabel'' doesn't work), add the location of the installed ''libopenbabel.so'' to the ''LD_LIBRARY_PATH'', in my case:
 
+
(B1) If you want to use OpenBabel from Python, you now need to compile the python extension. This may require an extra Python package depending on your Linux distribution. For example, for Debian you need the 'python-dev' package (installed using 'apt-get'); for SUSE, you need 'python-devel' (installed using YaST).
+
 
+
Change directory to 'openbabel-2.0.2/scripts/python' and run:
+
 
+
 
<pre>
 
<pre>
python setup.py build
+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
 
</pre>
 
</pre>
 
(B2) To install the python interface globally, as root type:
 
 
<pre>
 
python setup.py install
 
</pre>
 
 
(B3) You may need to add the location of libopenbabel.so.1 (on my system, the location is /usr/local/lib) to the environment variable LD_LIBRARY_PATH if you get the following error when you try to import the OpenBabel library at the Python prompt:
 
<pre>
 
$ python
 
>>> import openbabel
 
Traceback (most recent call last):
 
  File "<stdin>", line 1, in ?
 
  File "/usr/lib/python2.4/site-packages/openbabel.py", line 9, in ?
 
  import _openbabel
 
ImportError: libopenbabel.so.1: cannot open shared object file: No such file or directory
 
</pre>
 
 
==== Install the Perl bindings globally ====
 
 
(C1) If you want to use OpenBabel from Perl, you now need to compile the Perl extension.
 
 
Change directory to 'openbabel-2.0.2/scripts/perl' and run:
 
 
<pre>
 
perl Makefile.PL
 
make
 
make test # (Optional - this runs a few standard tests)
 
</pre>
 
 
On an MacOSX system, you may get the following error when you run 'make':
 
<pre>
 
/usr/bin/ld: flag: -undefined dynamic_lookup can't be used with MACOSX_DEPLOYMENT_TARGET environment variable set to: 10.1
 
</pre>
 
 
If this happens, you should set the value of the MACOSX_DEPLOYMENT_TARGET environment variable to match the MacOSX major version. For example, if you are using MacOSX 10.4.9, set MACOSX_DEPLOYMENT_TARGET to 10.4. Now run 'make' again.
 
 
(C2) To install the Perl bindings globally, as root type:
 
 
<pre>
 
make install
 
</pre>
 
 
(C3) You may need to add the location of libopenbabel.so.1 (on my system, the location is /usr/local/lib) to the environment variable LD_LIBRARY_PATH if you get an error when you try to import the OpenBabel library in a Perl script.
 
  
 
== Installing locally without root access ==
 
== Installing locally without root access ==
Line 112: Line 73:
 
If you don't have root access, you can still compile and use Open Babel.
 
If you don't have root access, you can still compile and use Open Babel.
  
(D1) Follow Step A1 above
+
(B1) Follow Step A1 above
  
(D2) Make a local directory to install everything into. In this example, I will use the folder "tree" in my home directory:
+
(B2) Make a local directory to install everything into. In this example, I will use the folder ''tree'' in my home directory:
 
<pre>
 
<pre>
 
mkdir /home/noel/tree
 
mkdir /home/noel/tree
 
</pre>
 
</pre>
  
(D3) Instead of Step A2 above, use the 'prefix' option of configure as follows:
+
(B3) Instead of Step A2 above, specify the install directory using the CMake option ''CMAKE_INSTALL_PREFIX'':
 
<pre>
 
<pre>
./configure --prefix=/home/noel/tree | tee configure.out
+
cmake ../ob-src -DCMAKE_INSTALL_PREFIX=/home/noel/tree 2>&1 | tee cmake.out
make | tee make.out
+
make 2>&1 | tee make.out
 
</pre>
 
</pre>
  
(D4) You can now install without root permissions using the following command:
+
(B4) You can now install without root permissions using the following command:
 
<pre>
 
<pre>
 
make install
 
make install
 
</pre>
 
</pre>
  
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):
+
This installs the ''obabel'' 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):
 
<pre>
 
<pre>
 
export PATH=$PATH:/home/noel/tree/bin
 
export PATH=$PATH:/home/noel/tree/bin
 
</pre>
 
</pre>
  
==== Install the Python bindings locally ====
+
(B5) Add the location of the installed ''libopenbabel.so'' to the ''LD_LIBRARY_PATH'', in my case:
 
+
(E1) To compile the Python extension, follow Step B1 above.
+
 
+
(E2) To install the Python extension, instead of Step B2 above, use the 'prefix' option to setup.py:
+
 
<pre>
 
<pre>
python setup.py install --prefix=/home/noel/tree
+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/noel/tree/lib
 
</pre>
 
</pre>
  
This installs the Python extension into something like /home/noel/tree/lib/python2.3/site-packages, so you need to add this directory to your PYTHONPATH in your startup scripts (that is, .bashrc, or whatever):
+
== Compile bindings for Java, .NET, Perl, Python or Ruby ==
<pre>
+
export PYTHONPATH=$PYTHONPATH:/home/noel/tree/lib/python2.3/site-packages
+
</pre>
+
 
+
(E3) As described in Step B3 above, you will probably also have to edit the variable LD_LIBRARY_PATH as follows:
+
<pre>
+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/oboyle/tree/lib
+
</pre>
+
 
+
==== Install the Perl bindings locally ====
+
 
+
(F1) To compile the Perl extension, instead of Step C1 above, use the 'PREFIX' option to Makefile.PL to specify an install location:
+
<pre>
+
perl Makefile.PL PREFIX=/home/noel/tree
+
make
+
make test # (Optional - this runs a few standard tests)
+
</pre>
+
 
+
(F2) To install the Perl extension, run the following:
+
 
+
<pre>
+
make install
+
</pre>
+
 
+
This installs the extension into something like /home/noel/tree/lib/perl/5.8.7, so you need to add "/home/noel/tree/lib/perl" to your PERL5LIB environment variable or specify this location in your Perl scripts as follows:
+
<pre>
+
use lib "/home/noel/tree/lib/perl"; # Must come before "use Chemistry::OpenBabel;"
+
</pre>
+
 
+
(F3) As described in Step C3 above, you will probably also have to edit the variable LD_LIBRARY_PATH as follows:
+
<pre>
+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/oboyle/tree/lib
+
</pre>
+
  
== Advanced Notes ==
+
To compile and install the bindings for the various languages supported, please see the appropriate page for [[Java]], [[OBDotNet | .NET]], [[Perl]], [[Python]], [[Ruby]].
  
* When compiling the Python extension, if you want to link to a version of Open Babel that is not in ../../src (relative to setup.py), /usr/local or /usr (this is the order in which these locations are searched), you should set OPENBABEL_INSTALL to point to the alternative location. There should be an "include/openbabel-2.0" and a "lib" directory at the location pointed to by OPENBABEL_INSTALL.
+
== Compile the development code ==
  
* If you need to recompile the SWIG bindings for the openbabel module, make sure you have the latest version of SWIG installed, and at Step A2 above, run configure as follows: <code>./configure --enable-maintainer-mode</code>
+
For information on compiling our development code, please see the [[CMake]] page.
  
 
[[Category:Installation]]
 
[[Category:Installation]]

Latest revision as of 04:10, 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 want to use Open Babel using one of the supported language bindings, then the following notes may apply:

You need the the Python development libraries to compile the Python bindings (package python-dev in Ubuntu)
You need the the Perl development libraries to compile the Perl bindings (package libperl-dev in Ubuntu)
Developer note: 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, 2.0.1, 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:

cd ob-build
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 the optional dependencies above).

#FIXME - INSERT EXAMPLE HERE

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

make install

(A4) If necessary (e.g. obabel 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, specify the install directory using the CMake option CMAKE_INSTALL_PREFIX:

cmake ../ob-src -DCMAKE_INSTALL_PREFIX=/home/noel/tree 2>&1 | tee cmake.out
make 2>&1 | tee make.out

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

make install

This installs the obabel 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.