Difference between revisions of "Compiling on Linux and Mac OS X"

From Avogadro - Free cross-platform molecule editor
Jump to: navigation, search
(Improve the flow a little)
(Updated and corrected the build instructions)
Line 1: Line 1:
These instructions are intended to help users 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. <br/>
+
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 [[Compiling_on_Windows|Windows Visual Studio 2008]] instructions, although building on Windows is much more problematic.
For the adventurous, there are also [[Compiling_on_Windows|Windows Visual Studio 2008]] instructions that may or may not work.
 
  
Generally, users should first try the binary installers or packages available on the [[:Get_Avogadro|download]] page, made using a released version of Avogadro.
+
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 [[:Get_Avogadro|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 ==
 
== 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. Make sure that you satisfy any version requirement given.
+
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.
  
 
;[http://subversion.tigris.org/ Subversion]
 
;[http://subversion.tigris.org/ Subversion]
 
;[http://git.or.cz/ Git] (optional, but recommended)
 
;[http://git.or.cz/ Git] (optional, but recommended)
;[http://www.cmake.org CMake] (>=2.4.7)
+
;[http://www.cmake.org CMake] (>=2.6.0)
 
;[http://trolltech.com/products/qt Qt4] (>=4.4.0)
 
;[http://trolltech.com/products/qt Qt4] (>=4.4.0)
 
;[http://eigen.tuxfamily.org/ Eigen2] (>=2.0_beta3) (more instructions [[#Installing Eigen|below]])
 
;[http://eigen.tuxfamily.org/ Eigen2] (>=2.0_beta3) (more instructions [[#Installing Eigen|below]])
 
;[http://openbabel.org/ OpenBabel] (>=2.2.0) (more instructions [[#Building OpenBabel|below]])
 
;[http://openbabel.org/ OpenBabel] (>=2.2.0) (more instructions [[#Building OpenBabel|below]])
  
For optional Python console/bindings:
+
For the optional Python console/bindings:
 
;[http://www.riverbankcomputing.co.uk/software/pyqt/download PyQt4]
 
;[http://www.riverbankcomputing.co.uk/software/pyqt/download PyQt4]
 
;[http://www.riverbankcomputing.co.uk/software/sip/download SIP]
 
;[http://www.riverbankcomputing.co.uk/software/sip/download SIP]
Line 24: Line 23:
  
 
== Installing Eigen2 ==
 
== Installing Eigen2 ==
Obtain the [http://eigen.tuxfamily.org/index.php?title=Main_Page#Download Eigen2 source] and enter the eigen2 source directory. Then build using:
+
You can obtain the [http://eigen.tuxfamily.org/index.php?title=Main_Page#Download Eigen2 source] and enter the eigen2 source directory. To download the latest sources do the following:  
 +
 
 
<code><pre>
 
<code><pre>
mkdir build
+
cd $HOME/src
cd build
+
svn co svn://anonsvn.kde.org/home/kde/trunk/kdesupport/eigen2 eigen2
cmake ..
 
make install # must be run as root or with sudo
 
 
</pre></code>
 
</pre></code>
  
'''Note:''' If you are either unable or do not want to install Eigen globally you can install in your home directly using:
+
Assuming you have the sources or the latest trunk of Eigen 2, it can be build and installed as follows:
  
<code><pre>
 
cd $HOME/src
 
svn co svn://anonsvn.kde.org/home/kde/trunk/kdesupport/eigen2 eigen2
 
 
cd eigen2
 
cd eigen2
 
mkdir $HOME/build/eigen2
 
mkdir $HOME/build/eigen2
Line 42: Line 37:
 
cmake $HOME/src/eigen2
 
cmake $HOME/src/eigen2
 
make
 
make
 +
sudo make install
 
</pre></code>
 
</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 ==
 
== Building OpenBabel ==
Avogadro makes heavy use of code and features from the [http://openbabel.org 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 by:
+
Avogadro makes heavy use of code and features from the [http://openbabel.org 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:
  
 
<code><pre>
 
<code><pre>
 +
cd $HOME/src
 
svn co https://openbabel.svn.sourceforge.net/svnroot/openbabel/openbabel/branches/openbabel-2-2-x openbabel-2.2
 
svn co https://openbabel.svn.sourceforge.net/svnroot/openbabel/openbabel/branches/openbabel-2-2-x openbabel-2.2
 
</pre></code>
 
</pre></code>
Line 53: Line 52:
 
Once you have the source code you can build it using:
 
Once you have the source code you can build it using:
 
<code><pre>
 
<code><pre>
 +
cd openbabel-2.2
 
./configure  
 
./configure  
make
+
make -j2
make install # must be run as root or with sudo
+
sudo make install
 
</pre></code>
 
</pre></code>
  
'''Note:''' If you are either unable or do not want to install OpenBabel globally you can install in your home directly using:
+
'''Note:''' If you are either unable or do not want to install OpenBabel globally you can skip the final make install step.
 
 
<code><pre>
 
cd $HOME/src
 
svn co https://openbabel.svn.sourceforge.net/svnroot/openbabel/openbabel/branches/openbabel-2-2-x openbabel-2.2
 
cd openbabel-2.2
 
./configure
 
make -j3
 
</pre></code>
 
  
 
== Building Avogadro ==
 
== Building Avogadro ==
  
Avogadro's version control system is now Git, 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 [http://github.com/cryos/avogadro/ here] by clicking on the download link. Generally you will want to clone the git repository,
+
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 [http://github.com/cryos/avogadro/ 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.
  
 
<code><pre>
 
<code><pre>
 
cd $HOME/src
 
cd $HOME/src
 
git clone git://github.com/cryos/avogadro.git
 
git clone git://github.com/cryos/avogadro.git
cd avogadro
 
 
mkdir -p $HOME/build/avogadro
 
mkdir -p $HOME/build/avogadro
 
cd $HOME/build/avogadro
 
cd $HOME/build/avogadro
 
cmake $HOME/src/avogadro
 
cmake $HOME/src/avogadro
make -j3
+
make -j2
 
sudo make install
 
sudo make install
 
</pre></code>
 
</pre></code>
  
'''Note:'''If you are either unable or do not want to install Avogadro globally you can install in your home directory using the following instructions. The instructions assume you have built Eigen and OpenBabel in your home directory.
+
'''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'''
 
'''Setting up the environment'''
Line 94: Line 85:
  
 
'''Building Avogadro'''
 
'''Building Avogadro'''
 +
 +
These instructions assume that the OpenBabel sources are compiled in your home directory but not installed.
 +
 
<code><pre>
 
<code><pre>
 
cd $HOME/src
 
cd $HOME/src
Line 103: Line 97:
 
   -DOPENBABEL2_LIBRARIES=$HOME/src/openbabel-2.2/src/.libs/libopenbabel.so \
 
   -DOPENBABEL2_LIBRARIES=$HOME/src/openbabel-2.2/src/.libs/libopenbabel.so \
 
   -DOPENBABEL2_VERSION_MET=true $HOME/src/avogadro
 
   -DOPENBABEL2_VERSION_MET=true $HOME/src/avogadro
make -j3
+
make -j2
 
</pre></code>
 
</pre></code>
  
Line 111: Line 105:
 
On Mac OS X Avogadro will be in your Applications folder.
 
On Mac OS X Avogadro will be in your Applications folder.
  
'''Note:''' If you've built Avogadro using the directions in the previous section then run Avogadro using:
+
'''Note:''' If you have built Avogadro using the directions in the previous section then run Avogadro using:
<code><pre>$HOME/build/avogadro/build/avogadro/src/avogadro</pre></code>
+
<code><pre>$HOME/build/avogadro/avogadro/src/avogadro</pre></code>
  
 
[[Category:User]]
 
[[Category:User]]

Revision as of 22:25, 28 December 2008

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