Four easy steps to install GEANT4 (Linux) | Entry

Source: Internet
Author: User
Tags arch linux

Recently started writing some articles for the subscription number "Geant4 Incomplete learning Guide".

The body begins.

Four easy steps to install GEANT4 (Linux) | Entry

软件版本:Ubuntu16.04,Geant4.10.04预备知识:Linux命令行终端的简单使用

GEANT4 official has adapted to mainstream computer platforms (Windows, Linux, MacOS), where the number of users is mostly Linux. So let's start with the installation on the Linux platform. Of course, Linux has more than one system, but there are various distributions issued by different manufacturers (Ubuntu, CentOS, Fedora, RedHat, Scientific Linux, Arch Linux, etc.). The differences between these systems can sometimes cause problems for Geant4, so we recommend that beginners use only officially tested systems. In the Geant 4.10.04 version, CENTOS7, scientific Linux CERN 6 and Ubuntu 16 are good choices. In particular, I recommend beginners from the Ubuntu system to get started, with CMake Automation Configuration tool, GEANT4 installation can be very simple. users do not even need to understand the technical details of CMake, follow the steps to enter the command terminal. Although the latest Ubuntu system is 17.10, but because Geant 4.10.04 has tested Ubuntu for the major version number 16, we recommend Ubuntu 16.04. If you want to install other versions of GEANT4, you can also check the release Note, using an officially tested system to avoid many problems.

1. System Preparation
#### 安装必需的库文件

Note: Libxmu-dev Libxi-dev has been renamed Libxmu-dev Libxi-dev under the new version of Ubuntu

2. Download Geant4

Download the latest version of geant4.10.04.tar.gz or Geant4.10.04.zip on Geant4 's website.

Unzip the file to a set location, such as/home/handbook/,

tar -xzvf geant4.10.04.tar.gz

Now we have the catalogue/home/handbook/geant4.10.04

3. Generate Makefile using CMake

Create the Build/folder under the/HOME/HANDBOOK/GEANT4.10.04/directory and enter

cd /home/handbook/geant4.10.04mkdir buildcd buiid/

We will use the CMake tool under the Build/folder to generate makefile, set/home/handbook/geant4.10.04 as the installation directory, install some necessary software support for GEANT4 (OpenGL, Raytracer and Gdml), and automatically download the database files that the physical simulation must have.

cmake -DCMAKE_INSTALL_PREFIX=/home/handbook/geant4.10.04 -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_RAYTRACER_X11=ON -DGEANT4_USE_GDML=ON -DGEANT4_INSTALL_DATA=ON ..

If the command works, it will probably end this way:

-- Configuring done-- Generating done-- Build files have been written to: /home/handbook/geant4.10.04/build
4. Compiling with the Make command

If your computer has n processors, you can use the following command

make –jN 否则只用 make

If the command works, it will probably end this way:

[100%] Building CXX object source /visualization/OpenGL/CMakeFiles/G4OpenGL.dir/src/G4OpenGLXViewer.cc.o[100%] Linking CXX shared library ../../../BuildProducts/lib/libG4OpenGL.so[100%] Built target G4OpenGL

Finally install the compiled file to the folder we just specified

make install

If the command works, it will probably end this way:

--Installing: /home/handbook/geant4.10.04/include/Geant4/G4OpenGLImmediateXViewer.hh-- Installing: /home/handbook/geant4.10.04/include/Geant4/G4OpenGLStoredX.hh-- Installing: /home/handbook/geant4.10.04/include/Geant4/G4OpenGLStoredXViewer.hh-- Installing: /home/handbook/geant4.10.04/include/Geant4/G4OpenGLXViewer.hh

Well, if there is no error, your installation is complete!

Let's simply verify that the GEANT4 is working properly. Geant4.10.04/examples There are a number of examples below that you can test. Let's pick one of the simplest examples examples/basic/b1

First, we're going to load the GEANT4 runtime environment

source ~/geant4.10.04/bin/geant4.sh

Then, we copy a code and compile it.

cd /home/handbookcp –r geant4.10.04/examples/basic/B1 .cd B1mkdir buildcd buildcmake ..make

If the command works, it will probably be:

[email protected]:~/B1/build$ makeScanning dependencies of target exampleB1[ 12%] Building CXX object CMakeFiles/exampleB1.dir/exampleB1.cc.o[ 25%] Building CXX object CMakeFiles/exampleB1.dir/src/B1EventAction.cc.o[ 37%] Building CXX object CMakeFiles/exampleB1.dir/src/B1DetectorConstruction.cc.o[ 50%] Building CXX object CMakeFiles/exampleB1.dir/src/B1SteppingAction.cc.o[ 62%] Building CXX object CMakeFiles/exampleB1.dir/src/B1ActionInitialization.cc.o[ 75%] Building CXX object CMakeFiles/exampleB1.dir/src/B1PrimaryGeneratorAction.cc.o[ 87%] Building CXX object CMakeFiles/exampleB1.dir/src/B1RunAction.cc.o[100%] Linking CXX executable exampleB1[100%] Built target exampleB1

After compiling, we get an executable program exampleB1 in the build/directory. After running, a visual interface will open, which means it's working.
./exampleb1

Four easy steps to install GEANT4 (Linux) | Entry

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.