李继飞做的GATE安装指南.doc
为了使用PET仿真平台,我装了大约一周,主要是中间出现各种问题,幸好可以借助google,baidu,以及那些先贤们的blog,终于历尽千辛万苦,成功攻克这一难题,仅以此文帮助那些后来者,本文包括如何安装CLHEP,安装geant4,安装root等等。其中Geant4部分主要借鉴了这样一篇文章在Ubuntu10.04.1下安装Geant4作者陶仕达等。总体来说PET仿真平台的安装更需要以下几篇文章基于 GATE 的 PET 仿真环境的实现与应用-张斌以及官网下载的gateinstallation Guide。另外文中很多问题是我遇到的,希望可以帮助你们!2012.07.19上海大学430实验室-李继飞我开始是用的ubtuntu10.04.1版本,把仿真平台装好后又升级到unbuntu12.04 LTS版本,我升级后发现一个问题,新版本的新立得包管理器竟然找不到从哪里用,恕我不才,至今不会用。所以老老实实的按照在Ubuntu10.04.1下安装Geant4来做就可以,等一切ok之后,再升级到Ubuntu 12.04 LTS版本。有的地方需要用管理员权限#来安装,否则会因权限不够,导致出现错误,到时候用命令sudo-i进入root#第一、安装GATE运行所必须的支撑库文件即安装基本编译环境:1. 安装基本编译环境sudo apt-get install build-essential2.安裝 OpenGL Librarysudo apt-get install libgl1-mesa-dev3. 安裝 OpenGL Utilitiessudo apt-get install libglu1-mesa-dev4. 安装 sudo apt-get install libxt-dev不装这个包在编译 geant4 时会报 error: X11/Intrinsic.h: No such file or directory 的错误。5. 安装 libxmu。打开新立得软件包管理器,查找 libxmu。把找到的七项全装上。(这里Ubuntu10.04.1就有新立得包管理器,而12.04就不能用,不知道为什么?)6. 安装 sudo apt-get install libxi-dev7. 确认系统已经安装了gcc:(ubuntu默认是已经安装的,我们这里只是确认一下它是哪个版本的,不太低就好)gcc -v第二、配置root运行的相关文件库,尤其是系统字体库,否则后面运行root时会出现:Couldn't find font "-adobe-helvetica-medium-r-*-*-10-*-*-*-*-*-iso8859-1",trying "fixed". Please fix your system so helvetica can be found,this font typically is in the rpm (or pkg equivalent) packageXFree86-75,100dpi-fonts or fonts-xorg-75,100dpi,这个问题我可是费了好大功夫才解决,这里特别感谢远在海外的邵立晶博士的指导!1. Install xfs and xfstt:命令为 sudo apt-get install xfs xfstt2. Install the following fonts: 命令为sudo apt-get install t1-xfree86-nonfree ttf-xfree86-nonfree ttf-xfree86-nonfree-syriac xfonts-75dpi xfonts-100dpi 也就是下面四个系统字体 t1-xfree86-nonfree 即- non-free Postscript Type 1 fonts from XFree86 ttf-xfree86-nonfree 即- non-free TrueType fonts from XFree86 ttf-xfree86-nonfree-syriac 即- non-free syriac OpenType fonts from XFree86 xfonts-75dpi 即- 75 dpi fonts for X xfonts-100dpi 即- 100 dpi fonts for X第三、安装CLHEP,血淋淋的教训呀!一定要一开始就把它装在geant4(我自己新建的文件夹)这个文件夹下到以下网站下载 CLHEP 数据包。http:/proj-CLHEP.web.cern.ch/proj-CLHEP/DISTRIBUTION/CLHEP.html,我下载的是版本2.0.4.51把下载的数据包放到某个文件夹例如home/fei/geant42解压CLHEP-2.0.4.5.tgzcd /home/fei/geant4tar -zxvf clhep-2.0.4.5.tgz成功安装会显示2.0.4.5/CLHEP/Vector/configure2.0.4.5/CLHEP/config.guess2.0.4.5/CLHEP/config.sub2.0.4.5/CLHEP/Makefile.in2.0.4.5/CLHEP/configure3 进入你解压出来的文件夹配置环境。命令如下:首先获取权限,因为是make和make install需要权限sudo -icd /home/fei/geant4/2.0.4.5/CLHEP./configure -prefix=/home/fei/geant4/CLHEP(这个地方要根据你想把CLHEP所装的位置来设置,这里的CLHEP是运行命令后自动产生的新目录,也就是我们的CLHEP安装目录,一会会用到该目录,注意绝对不能是/2.0.4.5/CLHEP,否则会出错),大约一分钟成功安装会显示config.status: creating test/exctest4.shconfig.status: creating test/exctestNothrow.shconfig.status: creating test/excDblThrow.shconfig.status: creating Exceptions/defs.hconfig.status: executing depfiles commands4 编译CLHEPmake大约三分钟,成功编译会显示rm -f libCLHEP-2.0.4.5.aliblist=./getObjectList -static Units Vector Evaluator GenericFunctions Geometry Random Matrix RandomObjects Cast RefCount Exceptions; ar cru libCLHEP-2.0.4.5.a $liblist; ranlib libCLHEP-2.0.4.5.arm -f libCLHEP-2.0.4.5.soliblist=./getObjectList -shared Units Vector Evaluator GenericFunctions Geometry Random Matrix RandomObjects Cast RefCount Exceptions; g+ -O -ansi -pedantic -Wall -D_GNU_SOURCE -g -O2 -o libCLHEP-2.0.4.5.so -shared -Wl,-no-undefined -Wl,-soname,libCLHEP-2.0.4.5.so $liblist -o libCLHEP-2.0.4.5.so./build-headermake1:正在离开目录 /home/fei/geant4/2.0.4.5/CLHEP'5 安装CLHEPmake install成功安装会显示test -z "/home/fei/geant4/CLHEP/include/CLHEP" | mkdir -p - "/home/fei/geant4/CLHEP/include/CLHEP"if test -f ClhepVersion.h; then echo " /usr/bin/install -c -m 644 'ClhepVersion.h' '/home/fei/geant4/CLHEP/include/CLHEP/ClhepVersion.h'" /usr/bin/install -c -m 644 "ClhepVersion.h" "/home/fei/geant4/CLHEP/include/CLHEP/ClhepVersion.h" else :; fi /usr/bin/install -c -m 644 'ClhepVersion.h' '/home/fei/geant4/CLHEP/include/CLHEP/ClhepVersion.h'make2: 没有什么可以做的为 install-data-am'。(这一句没有关系,呵呵,看到也不要担心)make2:正在离开目录 /home/fei/geant4/2.0.4.5/CLHEP'make1:正在离开目录 /home/fei/geant4/2.0.4.5/CLHEP'这样,我在/home/fei/geant4/CLHEP目录里看到include和lib两个目录,表示CLHEP安装成功。那么我的CLHEP安装路径就是/home/fei/geant4/CLHEP,到时我们会用到这个路径注意用命令exit退出终端第四、下载安装GEANT4重新进入终端1. 到以下网站下载你所需的数据包 。http:/geant4.web.cern.ch/geant4/,在soucefiles选择所需版本2. 解压 geant4.9.3.p02.tar.gz。把下载的压缩包解压到某一个文件夹。cd /home/fei/geant4tar -zxvf geant4.9.3.p02.tar.gz成功解压会显示geant4.9.3.p02/source/visualization/modeling/src/G4TrajectoryParticleFilter.ccgeant4.9.3.p02/source/visualization/modeling/src/G4VModel.ccgeant4.9.3.p02/source/visualization/modeling/src/G4VTrajectoryModel.ccgeant4.9.3.p02/source/visualization/modeling/src/G4VisTrajContext.cc3. 另外在data里下载各种data files(我是下载了所有的data files ,管它是干什么用的呢),在你 geant4.9.3.p02 文件夹里新建一个名为data 的文件夹,把下载的 G4EMLOW.6.9.tar.gz等数据包(我下载了7个包)放进去,逐个解压(其他数据包同理)。解压命令如下:cd /geant4.9.3.p02/datatar -zxvf G4EMLOW.6.9.tar.gz然后重复,一直把这七个包都解压完。成功解压会显示G4EMLOW6.9/tripdata/pp-trip-cs-95.datG4EMLOW6.9/tripdata/pp-trip-cs-96.datG4EMLOW6.9/tripdata/pp-trip-cs-97.datG4EMLOW6.9/tripdata/pp-trip-cs-98.datG4EMLOW6.9/tripdata/pp-trip-cs-99.dat接着逐个解压其他的data文件4. 配置环境:进入 geant4.9.3.p02 文件夹配置环境。命令如下:cd /home/fei/geant4/geant4.9.3.p02./Configure -build回答问题。输入以上两条命令按回车后,你将在终端被问一系列问题,除以下两个问题外,全部采用默认设置。问题一:When it asks:Enable building of the X11 OpenGL visualization driver? nEnter: yThis tells Geant4 that you want to include the optional OpenGL Visualizationdriver.问题二:When it asks:Enable building of the X11 RayTracer visualization driver? nEnter: yThis tells Geant4 that you want to include the optional RayTracerX Visualizationdriver.如果问找不到CLHEP,则手动输入为/home/fei/geant4/CLHEP,也就是包括lib和inclde文件的那个目录其他的就一顿enter就可以,只要出问题答案不对,它会提示你的,而且就自动停止,直到你解决问题。问题回答完后,终端将显示如下内容Press Enter to start installation or use a shell escape to editconfig.sh:5. 安装GEANT4 按下回车,开始安装,这时在终端可以看到Now starting Geant4 libraries build.当你看到以下内容的时候,我又要恭喜你,你的编译已经成功开始了。内容如下:Compiling G4AllocatorPool.cc .即使看到一大堆warning也不要紧,它是由gcc编译器本身引起的,直接忽视,不会有影响的!6. 安装成功,继续等上个 40 分钟左右,如果你看到以下内容的话,恭喜你,你的 Geant4 至此已经安装成功了。当然你不必坐在电脑前干等,插上电源线,趁机去洗个衣服或吃个饭什么的都行。大爷的,我怎么没早看到,白白坐了半天。另外务必注意,不要随便动终端,血的教训呀,我装了大概30分钟时,切换qq,不知怎么回事鼠标切到终端里了,结果悲剧呀编译暂停,害我又重新装了40分钟!安装成功会显示:# Your Geant4 installation seems to be successful! # To be sure please have a look into the log file: # /home/fei/geant4/geant4.9.3.p02/.config/bin/Linux-g+/g4make.log #第五、运行应用程序1. 创建Geant4脚本,命令如下./Configure会看到以下内容 - Geant4 Toolkit Installation - (setting environments for USER )-The Geant4 toolkit installation was found.The files env.csh will be copied to your current directory.For setting Geant4 environments you should make:source env.cshor. env.shIt will also check G4WORKDIR setting and set it toyour HOME if needed.You can use these files also for further modifications(adding your own environments).-这样,你将在home/fei/geant4/geant4.9.3.p02目录下看到两个文件env.sh 和 env.csh 两个文件2. 创建Geant4工作目录:首先创建一个文件夹命名为g4work,注意不要放在geant4的安装目录GEANT4.9.3.P02里。g4work将作为我们geant4的工作目录,这样做是为了防止破坏原始geant4的安装目录。在终端命令如下export G4WORKDIR=/home/fei/geant4/g4work3. 把应用程序复制到工作目录:这里选择A01,直接在终端敲入命令如下cp -r /home/fei/geant4/geant4.9.3.p02/examples/extended/analysis/A01 $G4WORKDIR/A01,这里务必要注意$前面有一个空格,否则会出现cp: 在"/home/fei/geant4/geant4.9.3.p02/examples/extended/analysis/A01/home/fei/g4work/A01" 后缺少了要操作的目标文件请尝试执行"cp -help"来获取更多信息。完成以后,我们在/home/fei/g4work就可以看到复制的应用文件A01.4. 配置应用程序运行环境。注意,每次在一个新终端运行应用程序时你都应该做这一步。命令如下:export G4WORKDIR=/home/fei/geant4/g4workexport LD_LIBRARY_PATH=/home/fei/geant4/CLHEP/lib/:$LD_LIBRARY_PATHsource /home/fei/geant4/geant4.9.3.p02/env.sh备注(我们装geatn4其实是为了一会装应用gate-v6.1,所以配置环境变量这一步以后用Gate的时候不用每次在终端输入,到时有专门的环境配置文件来做,一会就会讲到。不过这里我们来检验geatn4是否安装成功的时候,还是需要每次都这样做的。)It will respond:On this machine the G4SYSTEM=Linux-g+On this machine the G4INSTALL=/home/fei/geant4/geant4.9.3.p02On this machine the G4LIB=/home/fei/geant4/geant4.9.3.p02/libOn this machine the G4LEVELGAMMADATA=/home/fei/geant4/geant4.9.3.p02/data/PhotonEvaporation2.0On this machine the G4RADIOACTIVEDATA=/home/fei/geant4/geant4.9.3.p02/data/RadioactiveDecay3.2On this machine the G4LEDATA=/home/fei/geant4/geant4.9.3.p02/data/G4EMLOW6.9On this machine the G4NEUTRONHPDATA=/home/fei/geant4/geant4.9.3.p02/data/G4NDL3.13On this machine the G4ABLADATA=/home/fei/geant4/geant4.9.3.p02/data/G4ABLA3.0On this machine the G4REALSURFACEDATA=/home/fei/geant4/geant4.9.3.p02/data/RealSurface1.0On this machine the CLHEP_BASE_DIR=/home/fei/geant4/CLHEPOn this machine the CLHEP_INCLUDE_DIR=/home/fei/geant4/CLHEP/includeOn this machine the CLHEP_LIB_DIR=/home/fei/geant4/CLHEP/libOn this machine the CLHEP_LIB=CLHEPOn this machine the G4UI_USE_TCSH=1On this machine the G4VIS_BUILD_OPENGLX_DRIVER=1On this machine the G4VIS_BUILD_RAYTRACERX_DRIVER=1On this machine the G4VIS_USE_OPENGLX=1On this machine the G4VIS_USE_RAYTRACERX=1On this machine the XMFLAGS=On this machine the XMLIBS=On this machine the XMFLAGS=On this machine the XAWFLAGS=On this machine the XAWLIBS=On this machine the G4LIB_BUILD_SHARED=15. 编译程序,进入你的应用程序文件夹编译程序,终端输入命令cd $G4WORKDIR/A01make如果成功则显示Creating shared library /home/fei/geant4/g4work/tmp/Linux-g+/A01app/libA01app.so .Compiling A01app.cc .Using global libraries .Linking A01app. Done!6. 运行生成的可执行文件。命令如下:$G4WORKDIR/bin/Linux-g+/A01app你将在终端看到如下内容:chamber2Physical0 chamber2Logical 1 ArgonGas wirePlane2Physical0 wirePlane2Logical 0 ArgonGas /chamber2 chamber2Physical1 chamber2Logical 1 ArgonGas wirePlane2Physical0 wirePlane2Logical 0 ArgonGas /chamber2 chamber2Physical2 chamber2Logical 1 ArgonGas wirePlane2Physical0 wirePlane2Logical 0 ArgonGas /chamber2 chamber2Physical3 chamber2Logical 1 ArgonGas wirePlane2Physical0 wirePlane2Logical 0 ArgonGas /chamber2 chamber2Physical4 chamber2Logical 1 ArgonGas wirePlane2Physical0 wirePlane2Logical 0 ArgonGas /chamber2 EMcalorimeterPhysical0 EMcalorimeterLogical 1 CsI cellPhysical-1 cellLogical 0 CsI /EMcalorimeter HadCalorimeterPhysical0 HadCalorimeterLogical 1 Lead HadCalColumnPhysical-1 HadCalColumnLogical 1 Lead HadCalCellPhysical-1 HadCalCellLogical 1 Lead HadCalLayerPhysical-1 HadCalLayerLogical 1 Lead HadCalScintiPhysical0 HadCalScintiLogical 0 Scintillator /HadCalorimeterIdle> 7. 打开视窗,查看你定义的几何模型。即在“Idle>”后输入以下命令:/vis/open OGLIX/vis/drawVolume你将在一个新窗口看到如下图形,这里省略了。8. 查看粒子径迹和粒子碰撞过程。即在终端继续输入如下命令:/vis/scene/add/trajectories/vis/scene/add/hits/run/beamOn 1图略9. 运行完毕退出,命令:exit第六、安装ROOT(这几个是我在root网张上看得,说是安装root需要的一些基本编译环境,所以我就安装了,具体什么用我也不清楚,貌似没多大用处,因为本身Ubuntu里已经默认安装好了大部分)sudo apt-get install subversionsudo apt-get install libx11-devsudo apt-get install libxpm-devsudo apt-get install libxft-devsudo apt-get install libxext-dev1. 到下述网站下载ROOT安装包http:/root.cern.ch/drupal/,我下载的是root_v5.34.01.source.tar.gz,而并不用binary版本一是因为太大,二是因为安装好像不太方便。把安装包放到/home/fei/geant4中2. 打开终端输入,并解压文件cd /home/fei/geant4tar -xvzf root_v5.34.01.source.tar.gz3. 编译获取权限sudo -icd /home/fei/geant4/root_v5.34.01(这里我把解压后产生的文件夹root重命名为root_v5.34.01,这是为了下一步预编译产生一个新的root安装目录)./configure -prefix=/home/fei/geant4/root(注意这里为什么更改root为root_v5.34.01呢?原因是安装目录和解压后的文件目录如果放在一块,会发生错误库文件调用,引起很大的麻烦)成功会显示Enabled support for asimage, astiff, builtin_afterimage, builtin_ftgl, builtin_glew, builtin_pcre, builtin_lzma, cintex, explicitlink, genvector, memstat, opengl, reflex, shadowpw, shared, tmva, x11, xft, xml.To build ROOT type: make make install4. make大约30分钟,如顺利则显示cp /home/fei/geant4/root_v5.34.01/cint/reflex/python/genreflex/genrootmap.py lib/python/genreflex/genrootmap.pycp /home/fei/geant4/root_v5.34.01/cint/reflex/python/genreflex/selclass.py lib/python/genreflex/selclass.py = = ROOT BUILD SUCCESSFUL. = = Run 'make install' now. = =5. make install成功会显示 = = ROOT BUILD SUCCESSFUL. = = Run 'make install' now. = =Installing binaries in /home/fei/geant4/root/binInstalling libraries in /home/fei/geant4/root/lib/rootInstalling headers in /home/fei/geant4/root/include/rootInstalling /home/fei/geant4/root_v5.34.01/main/src/rmain.cxx in /home/fei/geant4/root/include/rootInstalling cint/cint/include cint/cint/lib and cint/cint/stl in /home/fei/geant4/root/lib/root/cintInstalling icons in /home/fei/geant4/root/share/root/iconsInstalling fonts in /home/fei/geant4/root/share/root/fontsInstalling misc docs in /home/fei/geant4/root/share/doc/rootInstalling tutorials in /home/fei/geant4/root/share/doc/root/tutorialsInstalling tests in /home/fei/geant4/root/share/doc/root/testInstalling macros in /home/fei/geant4/root/share/root/macrosInstalling man(1) pages in /home/fei/geant4/root/share/man/man1Installing config files in /etc/rootInstalling Autoconf macro in /home/fei/geant4/root/share/aclocalInstalling Emacs Lisp library in /home/fei/geant4/root/share/emacs/site-lispInstalling GDML conversion scripts in /home/fei/geant4/root/lib/root6. 配置ROOT环境变量Add bin/ to PATH and lib/ to LD_LIBRARY_PATH.即添加路径,直接在终端输入下列命令:. bin/thisroot.sh(注意是. bin/thisroot.sh,里面有个点)退出终端重新进入7. 运行root看是否成功安装source /home/fei/geant4/root/bin/thisroot.shroot会看到 feiubuntu:$ source /home/fei/geant4/root/bin/thisroot.shfeiubuntu:$ root * * * * W E L C O M E to R O O T * * * * Version 5.34/01 13 July 2012 * * * * You are welcome to visit our Web site * * http:/root.cern.ch * * * *ROOT 5.34/01 (tags/v5-34-0145048, Jul 13 2012, 15:31:31 on linux)CINT/ROOT C/C+ Interpreter version 5.18.00, July 2, 2010Type ? for help. Commands must be C+ statements.Enclose multiple statements between .root 0 强制关掉终端开始下一步第七、安装gate1.首先安装ecat和lmf(什么用处,目前我还不知道),下载http:/www.opengatecollaboration.org/InstallingGATE放到文件夹geant4中后,解压缩,命令:cd /home/fei/