Five easy steps to install GEANT4 (Windows Chapter) | Entry

Source: Internet
Author: User

Because of the CMake Automation Configuration tool, installing GEANT4 on the Windows platform is almost as convenient as the Linux platform. Unlike using Linux, it is more encouraged to use the integrated development environment, Visual Studio (VS), to compile the installation. Let's take a brief look.

System environment: WINDOWS10, Visual Studio (community), CMake 3.10, Geant4.10.04

1. System Preparation

First download installs visual Studio 2017 and the latest version of CMake, the author uses the community (community) version of VS and the 3.10 version of CMake.

(a) the C + + toolkit needs to be added after installing vs: check Tools > Get Tools and Features install the required C + + compilation tools.

To verify that the C + + toolkit is installed correctly, you can select Tools > Visual Studio Command Prompt , open the command terminal in VS, and enter cl . If this command is not found, it is unsuccessful.

D:\>clMicrosoftC/C++ Optimizing Compiler Version 19.12.25835 for x86CopyrightMicrosoft Corporation.  All rights reserved.usage: cl [ option... ] filename... [ /link linkoption... ]

(b) The installation process of the CMake needs to be selected Add CMake to the System PATH for all users .

2. Download Geant4

To Geant4 official website to download the latest version geant4.10.04.zip, extract to the specified location, such as D, so we have a folder D:\geant4_10_04, we create a folder D:\geant4_10_04\ Build is used to store temporary files for a compiled installation.

3. Compiling

The following operations require a simple DOS command.

Open Tools > Visual Studio Command Prompt and run CMake in the build folder of the D drive.

> D:> cd geant4_10_04/build> cmake -DCMAKE_INSTALL_PREFIX="D:\geant4_10_04" -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_OPENGL_WIN32=ON "D:\geant4_10_04"

Note: The OPENGL option here is not geant4_use_opengl_x11, but _win32 end.

If you see a similar output, it is successful, especially if the selected features such as datasets and OpenGL are actually turned on.

-- configuring download of Missing DataSet G4neutronxs (1.4) -- configuring download of missing DataSet G4pii (1.3) -- configuring download of missing DataSet Realsurface (2.1) -- configuring Download of missing DataSet G4saiddata (1.1) -- configuring download of missing DataSet G4abla (3.1 ) -- configuring download of missing DataSet G4ensdfstate (2.2) -- the Following GEANT4 features is Enabled:GEANT4_BUILD_CXXSTD : Compiling against C + + standard  ' one '  geant4_use_opengl_win32 : Build OPENGL driver with Win32 Support-- configuring Done-- generating Done-- Build Files have been written to:d:/geant4_10_04/build  

Run the following command to compile the Geant4.

> cmake --build . --config Release

If the output has a similar ending, then there should be no problem.

FinalizeBuildStatus:  Deleting file "Win32\Release\ALL_BUILD\ALL_BUILD.tlog\unsuccessfulbuild".  Touching "Win32\Release\ALL_BUILD\ALL_BUILD.tlog\ALL_BUILD.lastbuildstate".Done Building Project "D:\geant4_10_04\build\ALL_BUILD.vcxproj" (default targets).Build succeeded.    0 Warning(s)    0 Error(s)
4. Installation
>cmake --build . --config Release --target install

The output should end like this:

  -- Installing: D:/geant4_10_04/include/Geant4/G4VisTrajContext.hh  -- Installing: D:/geant4_10_04/include/Geant4/G4VisTrajContext.iccFinalizeBuildStatus:  Deleting"Win32\Release\INSTALL\INSTALL.tlog\unsuccessfulbuild".  Touching"Win32\Release\INSTALL\INSTALL.tlog\INSTALL.lastbuildstate".Done"D:\geant4_10_04\build\install.vcxproj" (default targets).Build succeeded.    0 Warning(s)    0 Error(s)

The above is already installed, but before you actually use it, set the environment variables.

5. Setting Environment variables

How to add environment variables please baidu yourself.

PATHAppend D:\geant4_10_04\binG4ensdfstatedataD:\geant4_10_04\share\Geant4-10.4.0\data\G4ENSDFSTATE2.2G4ledataD:\geant4_10_04\share\Geant4-10.4.0\data\G4EMLOW7.3G4levelgammadataD:\geant4_10_04\share\Geant4-10.4.0\data\PhotonEvaporation5.2G4saidxsdataD:\geant4_10_04\share\Geant4-10.4.0\data\G4SAIDDATA1.1G4neutronhpdataD:\geant4_10_04\share\Geant4-10.4.0\data\G4NDL4.5G4neutronxsdataD:\geant4_10_04\share\Geant4-10.4.0\data\G4NEUTRONXS1.4G4piidataD:\geant4_10_04\share\Geant4-10.4.0\data\G4PII1.3G4radioactivedataD:\geant4_10_04\share\Geant4-10.4.0\data\RadioactiveDecay5.2G4realsurfacedataD:\geant4_10_04\share\Geant4-10.4.0\data\RealSurface2.1G4abladataD:\geant4_10_04\share\Geant4-10.4.0\data\G4ABLA3.1
Test for example EXAMPLE/BASIC/B1
>cd example/basic/B1>mkdir build>cd build>cmake -DGeant4_DIR="D:\geant4_10_04\lib\Geant4-10.4.0" ..>cmake --build . --config Release

The output of the first cmake is similar to this

--Building for:visual Studio 15 2017--The C compiler identification is MSVC 19.12.25835.0--The CXX compiler identification is MSVC 19.12.25835.0--Check for working C Compiler:c:/program Files (x86)/microsoftVisual Studio/2017/community/vc/tools/msvc/14.12.25827/bin/hostx86/x86/cl.exe--Check for working C Compiler:c:/program Files (x86)/microsoftVisual Studio/2017/community/vc/tools/msvc/14.12.25827/bin/hostx86/x86/cl.exe--Works--detecting C Compiler ABI Info--detecting C Compiler ABI Info-done--Check for working CXX Compiler:c:/program Files (x86)/microsoftVisual Studio/2017/community/vc/tools/msvc/14.12.25827/bin/hostx86/x86/cl.exe--Check for working CXX Compiler:c:/program Files (x86)/microsoftVisual Studio/2017/community/vc/tools/msvc/14.12.25827/bin/hostx86/x86/cl.exe--Works--detecting CXX Compiler ABI Info--detecting CXX Compiler ABI Info-done--Detecting CXX Compile Features--Detecting CXX Compile Features-done--Configuring done--Generating done--Build files have been written to:d:/examples/basic/b1/build

The second cmake output should tell you if the compilation is successful.

build  succeeded.  target  (1)  ->    target  (3)  ->   (clcompile  target ->  d : \geant4_10_04\include\geant4\g4mergemode.hh (page) :  warning C4715 :  ' g4accumulables::getmergefunction<double> ' : Not all control  paths return a value [D:\examples\basic\B1\build\exampleB1.vcxproj] 1  Warning (s) 
           
            0 
            Error (s)  

If it succeeds, we will have a folder with executable Release program exampleB1 in it. We can go to the folder by double-clicking to run, but the visualization is used here, so please copy the vis.mac and init_vis.mac to release under the Build folder.

After double-click Run, if you see a visual detector, then congratulations, the installation was successful.

Finally, I would like to explain that although GEANT4 officially provides solutions for the Windows platform, we recommend using GEANT4 under Linux.

This article is originally contained in the subscription number "Geant4 Incomplete learning Guide"

Five easy steps to install GEANT4 (Windows Chapter) | Entry

Related Article

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.