Build on Linux and Mac OS X

Updated build instructions are available on https://github.com/sys-bio/roadrunner/wiki/Building-from-Source.  The following is for reference only.
On Mac or Linux, all dependencies for roadrunner are either already installed or can easily be installed with a few simple commands to the package manager. The only difference is on Linux (Ubuntu), you use apt-get as your package manager. On Mac OSX, we found that brew is far and away the best, most functional and complete package manager. It can be installed from http://brew.sh/
On Linux (Ubuntu >= 12.04), use apt-get, on Mac OSX, just substitute ‘brew’ for apt-get
1: Install dependencies on Linux:
1.1.1: Install llvm (supported versions are 3.2-3.5).
apt-get install llvm-3.5-dev
1.1.2: Install the python development header files
apt-get install python2.7-dev
1.1.3: Install numpy
apt-get install python-numpy
1.1.4: Install swig
apt-get install swig2.0
1.1.5: Install git
apt-get install git
1.1.6 install cmake
apt-get install cmake
1.1.7 Install cmake-curses-gui
apt-get install cmake-curses-gui
1.1.8 Install xml2 header files (required by libsbml)
apt-get install libxml2-dev
1.2.1 On OSX, using brew, these become
brew install llvm33
brew install swig
brew install git
brew install cmake
1.2.2 On OSX, we have found the official Python 2.7 installers from python.org work very well. However, it is not required as OSX 10.6 already comes with Python 2.6 and numpy 1.2.1 which is sufficient for building roadrunner.
2: Grab the source code, I always like to make a ‘src’ directory in my home directory where I have all my source code.
mkdir ~/src
Go here, and grab the source code:
git clone https://github.com/sys-bio/roadrunner.git
(Alternatively) Download and untar, the source code release version,
tar -xvzf libroadrunner-[version]-src.tar.gz, from http://sourceforge.net/projects/libroadrunner/files/
Now, make a couple of directories where you will build the roadrunner and roadrunner third party projects.
mkdir rrbuild
mkdir rrtpbuild
I always like to build all packages into a $HOME/local directory, this way I don’t mess with the system files and can delete the whole thing at any time.
mkdir ~/local
3: Build
Go into the rrtpbuild dir and run
ccmake ../roadrunner/third_party/
This will bring up the ccmake config editor, change the build type to Release, and the CMAKE_INSTALL_PREFIX var to where you want the output to go, e.g. /home/andy/local.
Press ‘c’ a few times to configure, then ‘g’ to generate the build make files. Them build and install with
make -j4 install
The -j4 is when you have 4 processors, if you have more or less, set the appropriate number. Note, this is how many processors the build will use to compile RoadRunner, it has no effect on the final generated programs.
Now, you can build the main RoadRunner package, to into your ‘rrbuild’ directory you just make, and ccmake the roadrunner source lib, i.e.
ccmake ../roadrunner
ccmake_roadrunner
Make sure that BUILD_LLVM, BUILD_SWIG_PYTHON, BUILD_TESTS are ON, and BUILD_PLUGINS is OFF. Set both THIRD_PARTY_INSTALL_FOLDER and CMAKE_INSTALL_PREFIX to your $HOME/local directory, i.e. /home/andy/local, and set CMAKE_BUILD_TYPE to Release.
The LLVM_CONFIG_EXECUTABLE tends to vary from system to system. If you have more than one version of LLVM installed, then you will have several different llvm-config programs, e.g. llvm-config, llvm-config-3.1, llvm-config-3.2. Make sure you choose either the 3.1, 3.2 or 3.3 version, preferable the highest version you have.
On OSX, CMake frequently has issues finding the correct python dir, particularly if you have multiple pythons installed. You should press ‘t’ for the advanced settings tab and check with the following CMake variables are set to:
PYTHON_EXECUTABLE                /usr/local/bin/python2.6
PYTHON_INCLUDE_DIR               /usr/local/include/python2.6
PYTHON_LIBRARY                   /usr/local/lib/libpython2.6.dylib
The preceding values where when I build the roadrunner binary using the python 2.6 from brew.  If you are using the official Python install, then your python settings should look like:
PYTHON_EXECUTABLE    
     /Library/Frameworks/Python.framework/Versions/2.7/bin/python
PYTHON_INCLUDE_DIR 
     /Library/Frameworks/Python.framework/Versions/2.7/Headers
PYTHON_LIBRARY    
     /Library/Frameworks/Python.framework/Versions/2.7/lib/
         libpython2.7.dylib
Press ‘c’ a couple times to configure then ‘g’ to generate the make files.
4: Set up your system to use RoadRunner.
The roadrunner Python package is completely self contained. The directory where you build roadrunner to will have a ‘site-packages’ directory. This will have the ‘roadrunner’ python package. Simple copy, or preferably symlink this into your python site-packages directory.
On Linux, this us usually $HOME/.local/lib/python2.7/site-packages
So, go into this directory, and
ln -s ~/local/site-packages/roadrunner ./
Or, if you want it available system wide, copy or symlink it into you system site-packages directory which is usually
/usr/local/lib/python2.7/site-packages
You can add the directories where you built roadrunner to you path and library paths by setting them in either your .bashrc in Linux or .profile in OSX with
export PATH=$HOME/local/bin:$PATH

# for OSX
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$HOME/local/lib      

# for Linux
export LIBRARY_PATH=$HOME/local/lib:$LIBRARY_PATH

# so you can compile applications,
# this adds this dir to you include path.
export CPATH=$HOME/local/include:$CPATH
If the roadrunner package is correctly in your python path, you can run the built in test with
python -m 'roadrunner.testing'
if your using python 2.7, or if your using python 2.6, then you have to run it from within python, i.e.
>>> import roadrunner.testing
>>> roadrunner.testing.runTester()

Note, there are some issues with certain versions of 32 bit version of gcc the version of LAPACK that is currently in our source tree. This issue only occurs with gcc and 32 bit builds. The clang compiler does not exhibit this issue. In order to work around it, you should disable optimization of C language files by changing the CMake CMAKE_C_FLAGS_RELEASE variable to -O0 -NDEBUG.