How to Perform Geant4 Visualization
on Linux
August 31, 1999
September 02,1999 (revised 1)
September 07,1999 (revised 2)
September 30,1999 (revised 3)
November 02,1999 (revised 4)
January 26, 2000 (revised 5)
Satoshi Tanaka (Fukui University)
1. Introduction
This Web page describes how to compile Geant4 for visualization on Linux with the following setting up: (1) CLHEP library version 1.4, STL library, and Mesa-3.0 (a free OpenGL library) are used for compiling Geant4 libraries and executables. (2) The DAWNFILE, OpenGL-Xlib and VRMLFILE drivers are adopted for Geant4 visualization. The description below is checked with RedHat Linux 6.0, and expected to be valid for many other Linux pacages.
2. Required C++ compiler (egcs) etc
In order to compile Geant4 and CLHEP 1.4, you need the egcs C++ (g++) compiler version 1.1. For example, the package of RedHat Linux 6.0 includes the right one. If you are using another package of Linux or an older version of RedHat Linux, you may have to update the egcs compiler. You may also have to update related libraries. You can know the installed version of the egcs compiler with the command "g++ -v". For more details, see the Web page of Naruto University of Education:
The egcs compiler includes the STL library, and you can use it by setting an environmental variable (or the corresponding C-macro in "/geant4/config/architecture.gmk") as follows:
% setenv G4USE_STL 1
3. Installation of CLHEP 1.4
You should obtain the CLHEP 1.4 source codes first. Detailed information on CLHEP is described at
http://wwwinfo.cern.ch/asd/lhc++/clhep/index.html .The installation of CLHEP is very easy:
% gtar xvzf clhep-1.4.0.0.tar.gz
% cd ./CLHEP
% autoconf
% ./configure
% gmake
% su
# gmake install
# cd /usr/local/lib
# ln -s libCLHEP-g++.a libCLHEP.a
In this default way of installation, CLHEP 1.4 is installed under "/usr/local/", i.e. "/usr/local/lib/" and "/usr/local/include/CLHEP/".
4. Installation of Mesa (OpenGL)
4.1 Mesa 3.0
You can obtain the source codes of Mesa-3.0 (a free OpenGL library) from the following Web site:
http://www.mesa3d.org . The installation is quite easy. If you want to install Mesa-3.0 under, for example, "/usr/local/Mesa-3.0/", do as follows:% gtar xvzf MesaLib-3.0.tar.gz
% cd Mesa-3.0
% gmake
(# Excecuting "gmake" without an argument displays list of supported platform.)
% gmake linux
% su
# mkdir /usr/local/Mesa-3.0
# cp -r ./lib /usr/local/Mesa-3.0
# cp -r ./include /usr/local/Mesa-3.0
# cd /usr/local/Mesa-3.0
# ln -s libMesaGL.a libGL.a
# ln -s libMesaGLU.a libGLU.a
If you have the RPM package of Mesa-3.0, you can install it as follows:
% su
# rpm -i Mesa-devel-3.0-X.i386.rpm
In this case, Mesa is installed under the directory "/usr/".
4.2 Mesa 3.1
You can obtain the source codes of Mesa-3.1 (a free OpenGL library) from the following Web site:
http://www.mesa3d.org . The installation is quite easy. If you want to install Mesa-3.1 under, for example, "/usr/local/Mesa-3.1/", do as follows:% gtar xvzf MesaLib-3.1.tar.gz
% cd Mesa-3.1
% gmake
(# Excecuting "gmake" without an argument displays list of supported platform.)
% gmake linux
% su
# mkdir /usr/local/Mesa-3.1
# cp -r ./lib /usr/local/Mesa-3.1
# cp -r ./include /usr/local/Mesa-3.1
If you have the RPM package of Mesa, you can install it as follows:
% su
# rpm -i Mesa-devel-3.1-X.i386.rpm
In this case, Mesa is installed under the directory "/usr/".
5. Installation of Fukui Renderer DAWN
See the following Web page:
Note 1:You must use DAWN 3.80 or after for Geant4 visualization.
Note 2: OpenGL mode of DAWN 3.80a should be compiled with Mesa 3.0,
though simple editing of DAWN's Makefile enables compilation with Mesa 3.1.
OpenGL mode of DAWN 3.80b, released at the end of January 2000,
can be compiled with any version of Mesa.
6. Setting environmental variables (1)
In order to compile Geant4 for visualization, you have to set several environmental variables beforehand. (Equivalently, you can also edit macros of GNUmakefile's in the directory "geant4/config/".).
Adding the following to your ".cshrc" allows you to perform Geant4 visualization with the DAWNFILE, OpenGL, and VRMLFILE drivers:
(You may have to do some coutomazation for your own setting up, of course.)
#####################################################
# Sample .cshrc for Geant4 visualization on Linux
#####################################################
###### 1. General setting
setenv G4SYSTEM Linux-g++
setenv G4USE_STL 1
setenv CLHEP_BASE_DIR /usr/local
# setenv CLHEP_BASE_DIR /usr/local/CLHEP
###### 2. UI
############ 2-1. Selection of (G)UI in installation of libraries
setenv G4UI_BUILD_TERMINAL_SESSION 1
setenv G4UI_BUILD_GAG_SESSION 1
############ 2-2. Selection of (G)UI in compiling executables
setenv G4UI_USE_TERMINAL 1
setenv G4UI_USE_GAG 1
###### 3. Visualization
############ 3-1. Home directory of Mesa
setenv OGLHOME /usr/local/Mesa-3.0
############ 3-2. Selection of visualization drivers
# in installation of libraries
setenv G4VIS_BUILD_DAWNFILE_DRIVER 1
setenv G4VIS_BUILD_OPENGLX_DRIVER 1
setenv G4VIS_BUILD_VRMLFILE_DRIVER 1
# setenv G4VIS_BUILD_DAWN_DRIVER 1
# setenv G4VIS_BUILD_OPACS_DRIVER 1
# setenv G4VIS_BUILD_OPENGLXM_DRIVER 1
# setenv G4VIS_BUILD_OPENINVENTOR_DRIVER 1
# setenv G4VIS_BUILD_RAYX_DRIVER 1
# setenv G4VIS_BUILD_VRML_DRIVER 1
############ 3-3. Selection of visualization drivers
# in compiling executables
setenv G4VIS_USE_DAWNFILE 1
setenv G4VIS_USE_OPENGLX 1
setenv G4VIS_USE_VRMLFILE 1
# setenv G4VIS_USE_DAWN 1
# setenv G4VIS_USE_OPACS 1
# setenv G4VIS_USE_OPENGLXM 1
# setenv G4VIS_USE_OPENINVENTOR 1
# setenv G4VIS_USE_RAYX 1
# setenv G4VIS_USE_VRML 1
7. Setting environmental variables (2)
The followings are templates for customizing the Geant4 DAWNFILE visualization driver and Fukui Renderer DAWN.
####################################################################
# Customization of the DAWNFILE and VRMLFILE visualization drivers
####################################################################
###### 4. Customization of the DAWNFILE driver and renderer DAWN
# Note: For renderer DAWN, "dawn -H" displays all available
# environmental variables.
############ 4.1 On-line use of DAVID (a volume-overlapping debugger)
#
# setenv G4DAWNFILE_VIEWER david
############ 4.2 Off-line visualization
# with the batch mode of renderer DAWN
# 1: batch mode
# a: batch-append mode (multi-page g4.eps file)
#
# setenv DAWN_BATCH a
############ 4.3 Selection of a PostScript viewerer
# in on-line and off-line visualization
# with renderer DAWN (The default is "ghostview")
#
# setenv G4DAWNFILE_PS_VIEWER gs
# setenv DAWN_PS_PREVIEWER gs
############ 4.4 Making the multi-window mode default
# 0: PostScript file generation (default)
# 1: multiple X-windows
#
# setenv G4DAWNFILE_MULTI_WINDOW 0
############ 4.5 Output directory of "g4.prim" and "g4.eps" files
# Note 1: The default is the current directory.
# Note 2: Do not forget to append "/"
#
# setenv G4DAWNFILE_DEST_DIR /tmp/
############ 4.6 Automatic increment of output file names
# USAGE: setenv G4DAWNFILE_MAX_FILE_NUM n
# (n: a positive integer)
# DAWN-format files: g4.prim, g4_1.prim, g4_2.prim,
# …, g4_(n-1).prim
# EPS files : g4.eps , g4_1.eps , g4_2.eps,
# …, g4_(n-1).eps
# Note: Be careful for "explosion" of your disk space.
#
# setenv G4DAWNFILE_MAX_FILE_NUM 10
8. Setting environmental variables (3)
(This section has not been completed yet.)
The followings are templates for customizing the Geant4 VRMLFILE visualization driver.
###### 5. Customization of the VRMLFILE driver
############ 5.1 On-line visualization of VRML files and
# selection a VRML viewer
#
# setenv G4VRMLFILE_VIEWER vrweb
9. Installation, compilation, and execution of Geant4
Installation of Geant4 libraries:
% cd geant4/source
% gmake
Compilation of an official example:
% cd geant4/examples/novice/N03
% gmake
Execution of Geant4 visualization:
(Edit "prerunN03.mac" beforehand to choose a default visualization driver, if necessary.)
% ../../../bin/Linux-g++/exampleN03
Idle> /run/beamOn