Install ROOT and Geant4 on Windows XP with Cygwin

Versions of the main software

  1. Cygwin 1.5.24-2
  2. ROOT 5.16/00
  3. CLHEP 1.9.2.2
  4. Geant4.8.0

First Install Cygwin (Updated 4.5.2010)

  1. Install cygwin from the website http://www.cygwin.com, using the web install method only.
  2. Make sure to select the software you want, in particular, all the X stuff.
  3. For ROOT and GEANT, install the development utilities (make, touch, g++ etc) and Open GL, see the Cygwin site for details. (I like to also have mc).
  4. There will be a long download time.
  5. When its finished, start the Cygwin application, ( the icon on your desktop with the black "C" and the green tongue). This starts a cygwin bash shell. Type some commands and explore the system.
  6. If the passwd and groups files are not created in /etc of cygwin, run mkpasswd and mkgroups to get them (will be prompted to do this in a cygwin shell).
  7. If you want your windows and linux directories to coincide, then you can set a symbolic link from /home/<user> in cygwin to /<path to windows users>/<user> in windows, and copy the .bash* files from the original cygwin <user> home into the new windows <user> home.
  8. Tune your .bashrc and .bash_profile files to your preference and enter the environment settings required for the ROOT and GEANT installs (see their installation pages)
  9. You should add Cygwin/X to your installation (by re-running the latest setup.exe, running setup, and) selecting the 'xinit' package from the 'X11' category. Following this process there will be an icon to launch X-Windows in the Start Menu.
  10. Once X is running, you should also go back to setup on the cygwin site and fetch "libX11" and all similar things and also "libXpm" and "libXft" stuff and libXext-devel for shape.h.
  11. Now proceed from here in the cygwin X-window.

Check the C++ and C Compiler Works

  1. To make a Hello-World program Take this text fragment into nedit, then save it as Hello-World.cc
    • Then issue
      g++ Hello-World.cc -o Hello-World
      
    • and run by saying
      Hello-World
      

Now install ROOT

  1. Download the ROOT source from http://root.cern.ch/
  2. Use the latest production version, which is 5.16/00 at the time of writing this document.
  3. Now, install ROOT. "cd" to the parent dir of where ROOT should be installed so "cd /cygdrive/c/" to have ROOT in /cygdrive/c/root). Open a cygwin bash shell, unpack root (assuming you downloaded ROOT to C:\install) by typing
    tar xzf /cygdrive/c/install/root_v...win32gcc.tar.gz
    
  4. The environment variables like PATH must be set properly (seee the note on the .bashrc file above)
    export ROOTSYS=/<where you instlled root>
    export PATH=$ROOTSYS/bin:$PATH
    export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH
    
  5. Building ROOT with cygwin/GCC consists of two steps:
    1. 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).
    2. Second build (compile and link) root
    3. Third, you make the map.
  6. Open a cygwin bash shell .....
    cd /cygdrive/c
    ./configure win32gcc 
    make
    make map
    
  7. After about 30 minutes to an hour you have the full glory of root available for use! Check it works .... Open a cygwin X-shell ... and type root.

Issues

Root version 4.05
If it gives an error with the file wingcc, then find an updated version on the web.
Root version 5.08
The above problem has gone

Cygwin was 1.5.18 and is now 1.5.19

Issue
The getline function has been changed in 1.5.19 and now conflicts with ROOT. So delete the getline function definition lines in /usr/include/sys.stdio.h
Issue
The d_ino parameter of the dirent structure in 1.5.19 has been dropped. So, force definition of _POSIX near line 3388 in $ROOTSYS/unix/src/YUnixSystem.cxx, thhen it wont try to use d_ino

Now Install Geant

  1. Decide on an install environment, and establish the environment variables. The example for the bash shell follows for CHLEP. You can put these commands into a file called "geant.sh Δ".
    export CLHEP_DIR=/cygdrive/c/cygwin/usr/local
    export PATH="$PATH:$CLHEP_DIR/bin"
    
  2. Install and build CLHEP as per the instructions at (http://www.cern.ch/clhep).
  3. The environment example for geant4 is
  4. Geant wants to know where is CLHEP
    export CLHEP_BASE_DIR=$CLHEP_DIR
    export CLHEP_INCLUDE_DIR=$CLHEP_DIR/include
    export CLHEP_LIB_DIR=$CLHEP_DIR/lib
    export CLHEP_LIB=CLHEP
    
  5. Geant wants to know where is the root build directory
    export G4INSTALL=/cygdrive/c/geant4.7.1
    export G4INCLUDE=$G4INSTALL/include
    export G4LIB=$G4INSTALL/lib
    
  6. Now select your system don't use compiler of MSVC++
  7. Simply go for a straight linux environment
    export G4SYSTEM=WIN32-g++
    
  8. Now choose where you will put the executables and put them in the path
    export G4WORKDIR="$HOME/My Documents/geant4"
    export G4TMP=$G4INSTALL/tmp
    export PATH="$PATH:$G4WORKDIR/bin/$G4SYSTEM"
    
  9. Now select various options ->
    export G4LIB_BUILD_STATIC=1
    #export G4LIB_USE_GRANULAR=1 
    export G4DEBUG=1
    
  10. to use the debugger or not
    export G4OPTIMISE=' '
    
  11. We will use ROOT to analyse not JAG or AIDA
    export G4ANALYSIS_USE=0
    export G4UI_USE_ROOT=1
    #export G4UI_USE_TCSH=1
    export G4UI_USE_TERMINAL=1
    export G4UI_USE_GAG=1
    export G4UI_USE_XAW=1
    export G4UI_USE_WO=1
    #export G4VIS_USE_OIX=0
    #export G4VIS_USE_DAWN=1
    #export G4VIS_USE_VRML=1
    
  12. This prepares for Open GL build
    export OGLHOME=/usr/X11R6
    export G4VIS_BUILD_OPENGLX_DRIVER=1
    
  13. Choose non-permanent graphics window, low memory option
    export G4VIS_USE_OPENGLX=1
    #export G4VIS_USE_OPENGLXM=1
    
  14. Start a new X-shell and make sure your environment variables come through (use shell scripts to automate their setting). Build geant4 (after reading about installation procedures at http://geant4.cern.ch/ just by saying (in the geant source directory)
    make
    
  15. Then test, by going to the novice N03 example tree and saying
    make
    
  16. You can add a new visualisation manager by the following minimal rebuild of the visualisation system
    touch $G4INSTALL/source/visualization/management/src/G4VisManager.cc
    cd $G4INSTALL/source/visualization/OpenGL; make clean
    cd $G4INSTALL/source/interfaces; make clean
    cd $G4INSTALL/source/; make
    
  17. Rebuild the your application as follows:
    cd /path/to/example
    gmake clean
    gmake
    
  18. For example, from the GEANT4 www-page, you can follow the link to the Installation Introduction, and from there to the Dawn pages, and get Dawn working as well.