Difference between revisions of "Install (source code)"
Baoilleach (Talk | contribs) (Instructions for non-root install) |
Baoilleach (Talk | contribs) (Rewrite of installation page No. 2) |
||
Line 1: | Line 1: | ||
− | == | + | == 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. | |
− | + | 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] | ||
+ | :: A C++ compiler (like g++) | ||
+ | :: A makefile system (like GNU make) | ||
− | ( | + | The following are optional when compiling Open Babel, but if not installed, it may restrict the features available: |
+ | :: Python is required to compile the Python bindings | ||
+ | :: Perl is required to compile the Perl bindings | ||
+ | :: 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) | ||
+ | :: 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 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]]. | ||
+ | |||
+ | == Installing globally with root access == | ||
+ | |||
+ | (A1) Open a command window, and | ||
decompress the downloaded file with following command: | decompress the downloaded file with following command: | ||
Line 14: | Line 28: | ||
This will create a folder called 'openbabel-2.0.2'. | This will create a folder called 'openbabel-2.0.2'. | ||
− | ( | + | (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 'openbabel-2.0.2'. Run the following commands, one after | ||
the other | the other | ||
Line 46: | Line 47: | ||
</pre> | </pre> | ||
− | ( | + | (A3) If you have root permissions, you can install openbabel globally. |
As root, run the following command: | As root, run the following command: | ||
Line 53: | Line 54: | ||
</pre> | </pre> | ||
− | ( | + | ==== Install the Python bindings globally ==== |
+ | |||
+ | (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: | Change directory to 'openbabel-2.0.2/scripts/python' and run: | ||
Line 61: | Line 64: | ||
</pre> | </pre> | ||
− | ( | + | (B2) To install the python interface globally, as root type: |
<pre> | <pre> | ||
Line 67: | Line 70: | ||
</pre> | </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> | <pre> | ||
$ python | $ python | ||
Line 78: | Line 81: | ||
</pre> | </pre> | ||
− | ==== Installing locally without root access | + | ==== Install the Perl bindings globally ==== |
+ | |||
+ | ...Fill me in... | ||
+ | |||
+ | == Installing locally without root access == | ||
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 |
− | ( | + | (D2) 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: |
<pre> | <pre> | ||
./configure --prefix=/home/noel/tree | tee configure.out | ./configure --prefix=/home/noel/tree | tee configure.out | ||
Line 95: | Line 102: | ||
</pre> | </pre> | ||
− | ( | + | (D4) You can now install without root permissions using the following command: |
<pre> | <pre> | ||
make install | make install | ||
Line 105: | Line 112: | ||
</pre> | </pre> | ||
− | + | ==== Install the Python bindings locally ==== | |
− | ( | + | (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 | python setup.py install --prefix=/home/noel/tree | ||
Line 117: | Line 126: | ||
</pre> | </pre> | ||
− | ( | + | (E3) As described in Step B3 above, you will probably also have to edit the variable LD_LIBRARY_PATH as follows: |
<pre> | <pre> | ||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/oboyle/tree/lib | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/oboyle/tree/lib | ||
</pre> | </pre> | ||
− | + | == Advanced Notes == | |
+ | |||
+ | * 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. | ||
− | * 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 | + | * 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> |
[[Category:Installation]] | [[Category:Installation]] |
Revision as of 02:12, 15 January 2007
Contents
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.
The following are required to compile Open Babel:
- The latest version of the Open Babel source code
- A C++ compiler (like g++)
- A makefile system (like GNU make)
The following are optional when compiling Open Babel, but if not installed, it may restrict the features available:
- Python is required to compile the Python bindings
- Perl is required to compile the Perl bindings
- SWIG is required to recreate the Python/Perl bindings (this is only necessary for developers...see Advanced Notes for more info)
- 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 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 following command:
tar zxvf openbabel-2.0.2.tar.gz
This will create a folder called 'openbabel-2.0.2'.
(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 the other
./configure | tee configure.out make | tee make.out
If there are any errors at this point, send an email to the openbabel-discuss mailing list and attach the files 'configure.out' and 'make.out'.
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).
... checking for libxml - version >= 2.6.5...yes (version 2.6.21) ... checking for zlib.h... yes
(A3) If you have root permissions, you can install openbabel globally. As root, run the following command:
make install
Install the Python bindings globally
(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:
python setup.py build
(B2) To install the python interface globally, as root type:
python setup.py install
(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:
$ 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
Install the Perl bindings globally
...Fill me in...
Installing locally without root access
If you don't have root access, you can still compile and use Open Babel.
(D1) 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:
mkdir /home/noel/tree
(D3) Instead of Step A2 above, use the 'prefix' option of configure as follows:
./configure --prefix=/home/noel/tree | tee configure.out make | tee make.out
(D4) You can now install without root permissions using the following command:
make install
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
Install the Python bindings locally
(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:
python setup.py install --prefix=/home/noel/tree
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):
export PYTHONPATH=$PYTHONPATH:/home/noel/tree/lib/python2.3/site-packages
(E3) As described in Step B3 above, you will probably also have to edit the variable LD_LIBRARY_PATH as follows:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/oboyle/tree/lib
Advanced Notes
- 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.
- 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:
./configure --enable-maintainer-mode