Compiling on Linux and Mac OS X

From Avogadro - Free cross-platform molecule editor
Revision as of 22:25, 28 December 2008 by Cryos (talk | contribs) (Updated and corrected the build instructions)
Jump to: navigation, search

These instructions are intended to help users and contributors build Avogadro from the latest code. Be aware that Avogadro may fail to build or work properly at any given time when built using the instructions below. For the adventurous, there are also Windows Visual Studio 2008 instructions, although building on Windows is much more problematic.

Generally, if you do not need the latest Avogadro features and are not interested in developing Avogadro, you should first try the binary installers or packages available on the download page. These are built using a released version of Avogadro which has received more testing than the current head of Git at any given moment.


Dependencies

You should be able to find most of these dependencies in your distribution's repositories, or as binary downloads for Mac from the homepages linked below. Be careful to satisfy the version requirements.

Subversion
Git (optional, but recommended)
CMake (>=2.6.0)
Qt4 (>=4.4.0)
Eigen2 (>=2.0_beta3) (more instructions below)
OpenBabel (>=2.2.0) (more instructions below)

For the optional Python console/bindings:

PyQt4
SIP
Boost

For optional OpenGL shader support:

GLEW

Installing Eigen2

You can obtain the Eigen2 source and enter the eigen2 source directory. To download the latest sources do the following:

cd $HOME/src
svn co svn://anonsvn.kde.org/home/kde/trunk/kdesupport/eigen2 eigen2

Assuming you have the sources or the latest trunk of Eigen 2, it can be build and installed as follows:

cd eigen2 mkdir $HOME/build/eigen2 cd $HOME/build/eigen2 cmake $HOME/src/eigen2 make sudo make install </pre></code>

Note: If you are either unable or do not want to install Eigen globally you can skip the final make install step.

Building OpenBabel

Avogadro makes heavy use of code and features from the OpenBabel chemistry toolbox. Avogadro needs OpenBabel 2.2.0 or more recent. If your distribution does not have a sufficiently recent version you may obtain it using:

cd $HOME/src
svn co https://openbabel.svn.sourceforge.net/svnroot/openbabel/openbabel/branches/openbabel-2-2-x openbabel-2.2

Once you have the source code you can build it using:

cd openbabel-2.2
./configure 
make -j2
sudo make install

Note: If you are either unable or do not want to install OpenBabel globally you can skip the final make install step.

Building Avogadro

Avogadro uses Git for version control, with hosting provided by GitHub. If you would rather not install Git it is possible to download a tar or zip file containing the latest sources from here. Click on the download link, unpack the file and adjust the instructions as necessary. It is generally a good idea to clone the repository if you intend to contribute or regularly build the latest sources.

cd $HOME/src
git clone git://github.com/cryos/avogadro.git
mkdir -p $HOME/build/avogadro
cd $HOME/build/avogadro
cmake $HOME/src/avogadro
make -j2
sudo make install

Note:If you are either unable or do not want to install Avogadro globally you can run in from your home directory using the following instructions. The instructions assume you have built Eigen and OpenBabel in your home directory too.

Setting up the environment

If you set these environment variables Avogadro and OpenBabel will use special directories for runtime plugin loading. Avogadro will search the subdirectories colors, engines, extensions and tools for suitable plugins. The environment variables can point to multiple directories separated by colons, i.e. "$HOME/.avogadro/plugins:/usr/local/lib/avogadro". All of them are optional, if they are installed then there is no need to set any environment variables.

export AVOGADRO_PLUGINS=$HOME/build/avogadro/libavogadro/src                                         #Avogadro Plugins
export BABEL_LIBDIR=$HOME/src/openbabel/src/formats/.libs:$HOME/src/openbabel/src/formats/xml/.libs  #Openbabel Formats
export BABEL_DATADIR=$HOME/src/openbabel/data                                                        #Openbabel Data Files

Building Avogadro

These instructions assume that the OpenBabel sources are compiled in your home directory but not installed.

cd $HOME/src
git clone git://github.com/cryos/avogadro.git
mkdir -p $HOME/build/avogadro
cd $HOME/build/avogadro
cmake \
  -DOPENBABEL2_INCLUDE_DIR=$HOME/src/openbabel-2.2/include \
  -DOPENBABEL2_LIBRARIES=$HOME/src/openbabel-2.2/src/.libs/libopenbabel.so \
  -DOPENBABEL2_VERSION_MET=true $HOME/src/avogadro
make -j2

Running

avogadro

On Mac OS X Avogadro will be in your Applications folder.

Note: If you have built Avogadro using the directions in the previous section then run Avogadro using:

$HOME/build/avogadro/avogadro/src/avogadro