This post has been archived. It's pretty old and likely concerns topics that are avoidable by using more modern tools and techniques. The original text is preserved below for posterity but it may no longer be relevant or correct.
Note: Running OS X 10.9 Mavericks or later? Check out the latest tutorial.
I recently found myself needing to install ROOT, the high energy physics framework by the folks at CERN. It wasn’t easy. The only 10.8 ROOT tutorial I’ve found uses the
make; make install path and doesn’t enumerate any of the available configuration options. (I wanted to use
cmake for the Xcode integration).
The following assumes you’re OK using the command line, though all the commands needed are given, and are running OS X 10.8 Mountain Lion. We’ll be installing ROOT to its own directory, so if something goes wrong during the install just delete the directory and try again.
Xcode, Apple’s development environment, is required before installing Homebrew. It’s available on the Mac App Store. Once it’s downloaded and installed, open Xcode, then open the following menu items in order:
Xcode, Preferences, Downloads, Components. Choose to install the “Command Line Tools” option.
Next, launch Terminal (inside
/Applications/Utilities/) and install Homebrew.
$ ruby <(curl -fsS https://raw.github.com/mxcl/homebrew/go) ... $ brew doctor
A lot of the warnings that
brew doctor produces can safely be ignored (at least for our purposes). If there’s any of them that look particular troubling, Googling almost always uncovers someone with the same problem.
Remember to add the Homebrew directory to your
PATH by adding the directory (found with
brew --prefix) to your
.zshrc or whatever shell file you’re using (
.bashrc is the OS X default). We’ll also add the XQuartz binaries to the
PATH in case anything needs them in the future.
Start a new Terminal session to pick up the changes.
Now that Homebrew is installed, we can use it to install the required dependencies. Each may take some time as Homebrew generally compiles from source.
$ brew install gfortran # Fortran compiler $ brew install python # Python interpreter $ brew install pcre # Regular Expressions library $ brew install fftw # Fast Fourier Transforms $ brew install cmake # Cross-platform make
You can read the post-install caveats any time by reading the appropriate recipe. (The only one to really take notice of is the Python installation, where you might like to use the symlinks provided and add the
install-scripts folder to your
That’s everything required for ROOT to install. Now to download and compile.
We’ll be installing ROOT in to the same directory that Homebrew installs things in to, but you can choose whichever directory you like (preferably one which your user owns to avoid lots of
sudo). Create the directory and download ROOT in to it with cURL.
$ cd /usr/local $ mkdir root $ cd root $ curl -O ftp://root.cern.ch/root/root_v5.34.01.source.tar.gz
Unzip the tarball and move it to a
$ gzip -dc root_v5.34.01.source.tar.gz | tar -xf - $ mv root/ src/
Good stuff. All that’s left is the compilation with
make. I stumbled a lot here, mainly because of X11. The compiler didn’t pick up my XQuartz install so couldn’t find
X11/Xlib.h. Luckily StackOverflow provided the answer, saying to pass the required directory as a compiler flag.
We use a few compilers here (
gfortran), so which compiler needs the flags? I got the compilation to work with the following.
$ export CFLAGS=-I/opt/X11/include $ export CXXFLAGS=-I/opt/X11/include $ export CPPFLAGS=-I/opt/X11/include
cmake to configure ROOT.
$ cmake /usr/local/root/src -DCMAKE_INSTALL_PREFIX=/usr/local/root -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -Droofit=ON
CXX_COMPILER are both Clang. If you don’t set these flags explicitly CMake may use the GNU compiler
gcc for the
C_COMPILER and Clang for the
CXX_COMPILER, which causes errors. We enabled Roofit for nice fits. If there any other ROOT options you want changed, the
cmake command is the place to specify them.
Now we can compile ROOT.
$ make -j 3
-j flag is the jobs flag and allows the compiler to execute multiple jobs simultaneously, rather than running a linear compilation. I’ve heard arguments saying that the integer argument should be related to the number of cores on your processor and the number of cores plus one. Both worked fine for me with a Core 2 Duo processor (
-j 2 and
-j 3). If you’re on a newer machine with a Core iX processor you might have 2, 4, or even 6 cores.
Assuming that worked without fatal errors (and if it did, congratulations! You’ve achieved the impossible) then there’s only one more step. If it didn’t work, you can contact me with the error message to try and sort something, or Google around with some key words from the error message.
$ make install
Finally, add ROOT to your
PATH using the same procedure as before, such that it might now look something like this.
Remember that this line should be in a shell config file such as
.bashrc. If you enter this line directly as a command, it will be lost in a new session.
With that, open a new shell session and try to run ROOT. You should see your X server start and a little ROOT splash window appear.
$ root ... root 
Now you’re ready to ROOT! To quit, use
.q. If you ever find your stuck in the ROOT command line, try
ctrl + c to interrupt.
It’s a good idea to run the demos to test the installation, using
.x to execute a file.
root .x /usr/local/root/src/tutorials/demos.C
There are many ROOT tutorials included inside
src/tutorials, and this Histogram tutorial gives a brief feel of the syntax. If you ever see a mention of
$ROOTSYS, this refers to the ROOT installation directory in
If you like, you can compile and run ROOT’s test suite. To do so, change directory in to
$ROOTSYS, run the
thisroot bash script, and then compile.
$ cd /usr/local/root $ . bin/thisroot.sh $ cd test/ $ make $ ./stress -b ... * ROOTMARKS =1444.7 * Root5.34/01 20120713/1049
We’ve installed Xcode, XQuartz, and Homebrew, which we’ve used to install all of the dependencies required for configuring and compiling ROOT. After downloading, configuring, compiling, and installing ROOT, we have ran a demo program to make sure it’s working.
This took me a few hours to figure out, using many online sources which I have tried to link to throughout. If you have problems getting ROOT up and running on 10.8 I’m happy to try and help, or you can try the ROOT message board.