Geant4.9.6.p01在Ubuntu12.10上的安装

(2013-03-23 17:50:27)


分类:geant4学习记
要点:1.安装完之后,删去build,节省硬盘容量(build属于安装文件,安装完了之后就没有用了)

2.若将geant4安装在根目录(/)下,则任何一步操作都得加上sudo,否则提示错误。

1.下载并解压源文件4.9.6.p01.tar.gz

2.建立build文件并进入其中,

3.配置:输入命令设置安装路径:首先输入命令

cmake -DCMAKE_INSTALL_PREFIX=/home/asd/geant4/install /home/asd/geant4/geant4.9.6.p01

再输入选择需要安装的可视化工具:

ccmake -DCMAKE_INSTALL_PREFIX=/home/asd/geant4/install /home/asd/geant4/geant4.9.6.p01


//CMAKE_INSTALL_PREFIX 相当于--prefix,如果没有该步,各系统的默认安装路径为Unix: /usr/local//Windows: C:ProgramFilesGeant4,参照http://www.oseye.net/question/96


4.在弹出来的窗口中选择需要安装的软件:如将GEANT4_INSTALL_DATA=ON而在线下载解压数据包(省去自己下载和解压),将GEANT4_USE_QT =ON而安装Qt可视化工具注意:若设为
GEANT4_USE_QT =ON,没有安装qt,则出现附录(1)的提示没有安装OpenGL则出现附录(2)

5.编译:make

6.安装:make install

7.
初始化环境变量:export G4LEDATA=/home/asd/geant4/install/share/Geant4-9.6.1/data/G4EMLOW6.32等

7.运行例子:cd N02

mkdir build

cd build

cmake -DGeant4_DIR=/home/asd/geant4/install/lib/Geant4-9.6.1 ..

make

./exampleN02




注意:

1.如果在安装中出现了问题,就根据提示安装需要的库文件即可,如安装ccmake窗口化命令包: sudo apt-get install cmake-curses-gui

2.Ubuntu下安装Qt:sudo apt-get install qt4-dev-tools qt4-doc qt4-qtconfig qt4-demos qt4-designer

其中qt4-dev-tools 包含了Qt Assistant及Qt Linguist等工具,因此不需要单独安装这两个工具。其它的,qt4-doc 是帮助文档,包含了Qt中各个类库的详细说明以及丰富的例子程序,可以使用Qt Assistant 工具来打开阅读。qt4-qtconfig 是配置Qt环境的一个对话框,一般默认就行了,很少有必要去更改。qt4-demos 包含很多可以运行起来的可执行文件以及源代码。qt4-designer是用来设计GUI界面的设计器。

附录:

(1)CMake Error at

/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97

(MESSAGE):

CouldNOTfindQt4 (missing: QT_QMAKE_EXECUTABLE QT_MOC_EXECUTABLE

QT_RCC_EXECUTABLE QT_INCLUDE_DIR QT_LIBRARY_DIR QT_QTCORE_INCLUDE_DIR

QT_QTCORE_LIBRARY QT_QTGUI_INCLUDE_DIR QT_QTGUI_LIBRARY

QT_QTOPENGL_INCLUDE_DIR QT_QTOPENGL_LIBRARY QT_UIC_EXECUTABLE)

Call Stack (most recent call first):

/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:288

(_FPHSA_FAILURE_MESSAGE)

/usr/share/cmake-2.8/Modules/FindQt4.cmake:1200

(FIND_PACKAGE_HANDLE_STANDARD_ARGS)

cmake/Modules/Geant4InterfaceOptions.cmake:86 (find_package)

CMakeLists.txt:84 (include)

(2)/home/asd/geant4.9.6.p01/source/visualization/OpenGL/src/G4OpenGLViewer.cc: 在成员函数‘virtual void G4OpenGLViewer::SetView()’中:

/home/asd/geant4.9.6.p01/source/visualization/OpenGL/src/G4OpenGLViewer.cc:297:47: 错误: ‘gluLookAt’在此作用域中尚未声明

/home/asd/geant4.9.6.p01/source/visualization/OpenGL/src/G4OpenGLViewer.cc: 在成员函数‘void G4OpenGLViewer::Pick(GLdouble, GLdouble)’中:

/home/asd/geant4.9.6.p01/source/visualization/OpenGL/src/G4OpenGLViewer.cc:428:53: 错误: ‘gluPickMatrix’在此作用域中尚未声明

In file included from /home/asd/geant4.9.6.p01/source/global/management/include/G4PhysicalConstants.hh:27:0,

from /home/asd/geant4.9.6.p01/source/global/management/include/globals.hh:70,

from /home/asd/geant4.9.6.p01/source/visualization/management/include/G4VViewer.hh:39,

from /home/asd/geant4.9.6.p01/source/visualization/OpenGL/include/G4OpenGLViewer.hh:38,

from /home/asd/geant4.9.6.p01/source/visualization/OpenGL/src/G4OpenGLViewer.cc:37:

/home/asd/geant4.9.6.p01/source/externals/clhep/include/CLHEP/Units/PhysicalConstants.h: 在全局域:

/home/asd/geant4.9.6.p01/source/externals/clhep/include/CLHEP/Units/PhysicalConstants.h:79:21: 警告: ‘CLHEP::electron_charge’定义后未使用 [-Wunused-variable]

make[2]: *** [source/visualization/OpenGL/CMakeFiles/G4OpenGL.dir/src/G4OpenGLViewer.cc.o] 错误 1

make[2]: *** 正在等待未完成的任务....

make[1]: *** [source/visualization/OpenGL/CMakeFiles/G4OpenGL.dir/all] 错误 2

make: *** [all] 错误 2