Friday, October 7, 2011

Installation of Geant4.9.4 on Ubuntu10.10 or Ubuntu10.04

2011-02-11
Install Ubuntu10.10 on VBox.
The installation lasted from 8:14PM to 8:44 PM.

2011-02-12

Set password for root account


In a terminal, type:
sudo passwd root
and then you can set a password for root user.
Now I want to build the Geant4 thoroughly by logging in username account but not root account.

Prerequisites:


1, install the essential compiling environment, otherwise, you can see error: C++ compiler cannot create executables for CLHEP
sudo apt-get install build-essential
2, install OpenGL library
sudo apt-get install libgl1-mesa-dev
3, install OpenGL utilities
sudo apt-get install libglu1-mesa-dev
4, avoid the error: X11/Intrinsic.h: No such file or directory in Geant4 installation.
sudo apt-get install libxt-dev
5, ubuntu software center, search: libxmu, and install all the seven available packages to avoid the error: include/G4OpenGLXViewer.hh; 46:29: error: X11/Xmu/StdCmap.h: No such file or directory.
6, A ubuntu10.10-specialized problem is that geant4 cannot find lXpm, so you have to search libXpm and install libxpm-dev, libxpm4-dbg, and libxpm4.
7, install Xerces C Parser if you want to use gdml in Geant4
Ubuntu software center, search Xerces, and then install:
Validating XML parser library for C++ (development files) (libxerces-c-dev)
And the libxerces-c3.1 will be installed together.
If you prefer libxerces-c2-dev, libxerces-c28 will be installed together.
NOTE: you can install either libxerces-c-dev or libxerces-c2-dev, but not both together.
Actually, I installed libxerces-c2-dev and libxerces-c28. I also installed libxerces-c3.1 manually.
The default location for headers is /usr/include/xercesc; for lib it is /usr/lib, etc.
If you download a full xerces from its website, you can install all the contents in one independent folder, so it will be easy to set the environment variable $XERCESCROOT.
In this software center installation method, we will set $XERCESCROOT=/usr
Put $XERCESCROOT/lib (actually it is /usr/lib) in /etc/ld.so.conf to avoid to see the error information in codeblocks that no $XERCESCROOT is found.
Add
export XERCESCROOT=/usr
in your .bashrc
8, install libXi to avoid the error: /usr/bin/ld cannot find -lXi
Software center, search libxi
And then install libxi6-dbg and libxi-dev and libxiterm1
Finally, you can see /usr/lib/libXi.a and libXi.so.
9, install open inventor driver (not recommended because it will result in incompatible problems with OpenScientist)
Software center search open inventor
Inventor-clients, inventor-doc, inventor-dev, inventor-data, libinventor0
The default location is /usr
10, install qt4
Software center, search libqt4-dev
Install libqt4-dev, and you will find several other useful packages, such as libqt4-opengl-dev, libqt4-designer are also installed together.
The default location is /usr
You can use:
qmake –v
to see the version of qt:
QMake version 2.01a
Using Qt version 4.7.0 in /usr/lib
11, java
Search OpenJDK in software center of Ubuntu and install it.
Add below lines in your .bashrc
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export JDK_HOME=$JAVA_HOME
export PATH=$JAVA_HOME/bin:$PATH
#open jdk
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

Installation of CLHEP2.1.0.1


Create a folder called G4install in your home directory, i.e.,  /home/username.
Unzip clhep-2.1.0.1.tgz into /home/username/G4install
Cd ~/G4install/2.1.0.1/CLHEP
Here ~ stands for your home directory /home/username
./configure --prefix /home/username/G4install/2.1.0.1
Then you can see the configuration procedure:
Checking build system type… i686-pc-linux-gnu
After a long while, when you see:
config.status: creating Exceptions/defs.h
config.status: executing depfiles commands
everything is OK.

make
When make ends, you can see:
./build-header
make[1]: Leaving directory `/home/username/G4install/2.1.0.1/CLHEP'
then you can install clhep via:
make install
Then you can see lib, include and bin folders are produced in the directory of 2.1.0.1, parallel to the CLHEP folder.
When you install geant4, it will ask you where the clhep is, you should answer:
/home/username/G4install/2.1.0.1
That is correct and enough.

Install Geant4


1, Download geant4.9.4 and data files.
2, Unzip geant4.9.4 in /home/username/G4install and in the geant4.9.4 directory, create a new folder named data and put all 9 data packages there and unzip them.
3, At first, use
printenv | grep G4
to see all the current environment variables containing “G4”.
If you can see them, please try to delete them before installing geant4.
4,
cd G4install/geant4.9.4/

5,
./Configure -build

Do you want to install all Geant4 headers in one directory? [n] y
Do you want to build shared libraries? [y] only *.so libraries will be produced
Do you want to build static libraries too? [n] I don’t want *.a libraries produced
Do you want to build global libraries? [y]
Do you want to build granular libraries as well? [n]
Do you want to build libraries with debugging information? [n] either y or n is OK

CLHEP_BASE_DIR:                                             /home/username/G4install/2.1.0.1
*OPTIONS FOR GEANT4 USER INTERFACE MODULES*
Enable building of User Interface (UI) modules? [y]
Enable building of the XAW (X11 Athena Widget set) UI module? [n]
Enable building of the X11-Motif (Xm) UI module? [n] y
You have selected to build the X11-Motif(Xm) based user interfaces.
Specify the correct path where Xm is installed on your system.
It was found in /usr. Press [Enter] to set this path or type the correct one.

You can set '-' (without quotation) to CANCEL the XM flag at all:
[/usr]
Enable building of the Qt UI module? [n] y
checking for qglobal.h... /usr/include/qt4/QtCore/qglobal.h
checking Qt major version... 4
checking for QtGui headers... yes
checking for QtOpenGL headers... yes
checking for QtCore library... QtCore
checking for moc... /usr/bin/moc-qt4

*OPTIONS FOR GEANT4 VISUALIZATION DRIVERS*
Enable building of visualization drivers? [y]
Enable building of the X11 OpenGL visualization driver? [n] y
Enable building of the X11-Motif OpenGL visualization driver? [n] y
Enable building of the FukuiRenderer/DAWN visualization driver? [n] y
Enable building of the X11 OpenInventor visualization driver? [n] y
Actually, we should choose n for OpenInventor, because OpenScientist cannot work correctly with this OpenInventor.
You have selected to build the X11 OpenInventor driver.
Specify the path where OpenInventor is installed on your system.
It was found in /usr. Press [Enter] to set this path or type the correct one.

You can set '-' (without quotation) to CANCEL the OpenInventor flag at all:
[/usr]
Enable building of the X11 RayTracer visualization driver? [n] y
Enable building of the VRML visualization driver? [n] y

You have selected to build one or more drivers that require OpenGL.
Specify the correct path (OGLHOME) where OpenGL is installed on your system.
It was found in /usr. Press [Enter] to set this path or type the correct one.

You can set '-' (without quotation) to CANCEL the OpenGL flag at all:
[/usr]
Enable building of the Qt OpenGL visualization driver? [n] y
configure: Qt already configured, no recheck neccessary

*OPTIONS FOR GEANT4 OPTIONAL EXTENSION MODULES*
Enable the Geometry Description Markup Language (GDML) module? [n] y
checking for XercesC install... /usr
Enable build of the g3tog4 utility module? [n] either y or n is OK
Enable internal zlib compression for HepRep visualization? [n] y

End of configuration phase.


Creating configuration setup file...

WARNING: the generated configuration file
can be edited if necessary!
You can introduce any change to the configuration file
/home/username/G4install/geant4.9.4/.config/bin/Linux-g++/config.sh before the final installation.
To do so, use a shell escape now (e.g. !vi /home/username/G4install/geant4.9.4/.config/bin/Linux-g++/config.sh).

Press [Enter] to start installation or use a shell escape to edit config.sh:

2:46pm, the build procedure began
3:51pm, the build procedure finished


Libraries installation completed !
If there were errors in your installation, i.e., cannot find lXpm, it will show:
############################################################
# It looks like you had errors during Geant4 installation  
# (or interrupted installation)!                                                    
# Please check log file:                                                                     
# /home/username/G4install/geant4.9.4/.config/bin/Linux-g++/g4make.log                       
############################################################

If everything is OK, you will see:
####################################################
# Your Geant4 installation seems to be successful! 
# To be sure please have a look into the log file: 
# /home/username/G4install/geant4.9.4/.config/bin/Linux-g++/g4make.log                       
####################################################


Only shared, global libraries will be built. i.e. *.so are produced in lib folder of geant4.9.4
If in this option, you choose n,
Enable internal zlib compression for HepRep visualization? [n] n
You will see the fatal error: zib.h: No such file or directory
But, actually, zlib.h is located in the folder /usr/include
If zlib.h really doesn’t exit, you can install it by:
Sudo apt-get install zliblg-dev
6,
./Configure -install
All the necessary headers will be copied into include folder of geant4.9.4
7,
./Configure
env.sh and env.csh are produced in geant4.9.4

8,
create a new folder named G4work in /home/username
9,
in your home directory,
gedit .bashrc
add below three lines:
export G4WORKDIR=$HOME/G4work
export LD_LIBRARY_PATH=$HOME/G4install/2.1.0.1/lib:$LD_LIBRARY_PATH
source $HOME/G4install/geant4.9.4/env.sh
10,
exit and restart a terminal
and you can see the environment variables related with geant4


2 comments:

  1. You can help me please to configure Code Blocks for run and programming in Geant4. I search all the web and nobody tell how to internaly configure Code Blocks that will run and conpile examples from Geant4. Thank you in advance, it will be great if you can help me with an advice or a link related to this proablem of integrating Geant4 in Code Blocks.

    ReplyDelete

happy time