Building ROOT on Windows using GCC

 

Introduction

This page will hopefully explain how to install or build ROOT, an object oriented data analysis framework, on windows, using GCC. You can get documentation on, source and binaries of ROOT at http://root.cern.ch. The goals of porting ROOT to windows with GCC (aka "win32gcc") were

  • to allow for a completely free and open source ROOT version for MS Windows,
  • to allow X11 GUIs on MS Windows, to allow the free usage of QT on MS Windows, and
  • windows - linux source compatibility (as far as possible).

If you encounter any problems with ROOT or the build you can get help from the ROOT Forum. If you have comments on this page please contact me.

 

Prerequisites To be able to build or run ROOT with GCC you need to install some packages (most of which you should have anyway when building ROOT for windows).
Installing the Binary Distribution Instead of building ROOT you can also just download it.
Build This part explains how to build ROOT with GCC.
Run Some few settings needed to run ROOT.
Hints for Cygwin-X11 A tiny collection of bits of experience I've collected with cygwin's X11 project - how to make things nicer, faster, better.

 

Prerequisites
These pages assume that you have ROOT (sources when building ROOT, the win32gcc binaries when installing it) and cygwin (i.e. binutils, make, bash, gcc, x11, x11-prog etc) installed. If you don't have ROOT or cygwin: download them - they're free.

Instead of building ROOT for win32gcc yourself you can also download the binaries from the ROOT download site directly. In that case cd to where ROOT should end up (actually, it will end up in a subdir called root, so cd to its parent dir, e.g. cd /cygdrive/c/ to have ROOT in /cygdrive/c/root). Now call tar xzf /cygdrive/c/install/root_v...win32gcc.tar.gz (assuming you downloaded it to C:\install). This will unpack root. Now you need to set PATH to include this new ROOT directory: export PATH=$PWD/root/bin:$PATH, and export ROOTSYS=$PWD/root (both HAVE to be unix style paths!). See below for a way to automate setting of $PATH and $ROOTSYS.

The ROOT win32gcc build is comparable to a regular unix gcc build, regarding settings used to build ROOT, ROOT's looks (X11 is X11) and ROOT's performance (at least when comparing i/o - the Xserver is a bit slower on cygwin...). This build also allows you to have the exact same sources on linux and on win32gcc - as long as they don't use semaphores etc, which are not yet implemented in cygwin. Check http://www.cygwin.com to see what is implemented and what is not.

 

Installing the Binary Distribution

Instead of building ROOT for win32gcc yourself you can also download the binaries from the ROOT download site directly. cd to where ROOT should end up (actually, it will end up in a subdir called root, so cd to its parent dir, e.g. cd /cygdrive/c/ to have ROOT in /cygdrive/c/root). Now call tar xzf /cygdrive/c/install/root_v...win32gcc.tar.gz (assuming you downloaded it to C:\install). This will unpack root. Now you need to set PATH to include this new ROOT directory: export PATH=$PWD/root/bin:$PATH, and export ROOTSYS=$PWD/root (both HAVE to be unix style paths!). See below for a way to automate the setting of $PATH and $ROOTSYS.

That's it, you're done. Before calling root you should start your X server (type startx), to allow ROOT to use windows (you don't need the X server when running ROOT in batch mode, e.g. with root -b).

 

Build

Building ROOT with cygwin/GCC consists of two steps: First, you need to initialize the build system (configure), telling it that we build for win32gcc then the build system needs to compile everything (via make). I will assume that your ROOT sources reside in C:\INSTALL - just as an example. We will build ROOT in C:\root - but you can do this anywhere you want, e.g. in /usr/shared (as long as the directory name does not contain spaces like Program\ Files). Also, the Windows environment variables TMP, TEMP, TMPDIR may not contain spaces, otherwise make fails when it tries to build the library "libfreetype.a" (thanks to Stilianos Kesisoglou for providing this hint).

Open a cygwin bash shell (the icon with the back "C" and the green tongue gets you there) and type:

cd /cygdrive/c
tar xzvf /cygdrive/c/install/root....tar.gz
cd root
export ROOTSYS=$PWD
./configure win32gcc --build=debug
make -j2 
make map

If you get a configure error because of missing libX11 libraries you haven't installed cygwin's x11 packages. Start cygwin's setup.exe and install it, then rerun the configure step. Good news: Parallel builds (make -j2) do work since ROOT's cvs from 2005-02-06, the future devel release version 4.03/02, or the pro version 4.04/00.

Note that ROOTSYS has to be set in UNIX format! After about 30 minutes to an hour you have the full glory of root available for use!

 

Run
To run ROOT you need to add it to your PATH variable (just as under Windows), and you need to set the environment variable ROOTSYS. You don't want to do this every single time, so let's put it into a file that gets executed automatically when you start cygwin. Assuming that cygwin is installed in C:\cygwin (doesn't matter, it's just an example), open the new file C:\cygwin\etc\profile.d\root.sh and insert these lines:
export ROOTSYS=/cygdrive/c/root
export PATH=$ROOTSYS/bin:$PATH
Now quit your cygwin bash shell (typing exit) and start a new one. If echo $ROOTSYS doesn't show what you wrote in /etc/profile.d/root.sh (this is the cygwin name for the above file) then there's something wrong with your .bashrc. Check cygwin and google on how to set up a .bashrc for cygwin.

In this new bash shell you should now start XWindows by typing startx. It will take a while - look down at the Hints section if you want to accelerate things. Usually, when starting X using startx, there should be one small ugly window on a plain background. This window is the graphics sister of the cygwin bash shell we used to start XWindows. It will know about $ROOTSYS and $PATH just as your cygwin shell did. It's called an xterm (because that is what you need to execute to get a new one).

Start root by typing root. Now your computer is busy for a while - I believe it needs to set up dll relocation tables or something. After a few seconds (maybe 20 or even 60) you will get the usual ROOT splash screen and the ROOT prompt. That's it, now you can use it. Next time you start ROOT (while being in the same session, i.e. while cygwin is still running) ROOT will start much faster. If anyone knows how to avoid these startup times (I've heard libGL might be causing this) please let me know.

If you ever get an error "Unable to remap..." you should call rebaseall -v (part of cygwin). It will ensure that all dlls are loaded into different parts of the memory, see an example for rebase, the underlying utility.

 

Hints for Cygwin-X11

Window Manager: KDE

The standard window manager (the program setting the looks of XWindows) is very efficient or ugly, depending on your point of view. The other extreme is KDE, also available for cygwin-X11 at http://kde-cygwin.sourceforge.net. KDE is much nicer, but it also eats up lots of memory, and it frequently accesses your hard drive (to simulate posix sockets). So if you get KDE, you might also want to get another 256MB RAM, and you might want to disable your virus scanner for a bit, until X11 and KDE are up.

Cygwin-KDE got a lot faster with the new KDE 3 - so if you want to save resources, do not download KDE 2, but take the newest one.

Do not install the KDE binutil patch (or any other patches from the KDE snapshot page)! This will break the linker ld, and ROOT will not compile!

 

 

Page maintained by Axel Naumann. Last updated on 2005-02-05.

  WEBCounter by GOWEB