|
|
# Geant4 Installation on Windows 11
|
|
|
|
|
|
<!--
|
|
|
For Geant4 version 11.2.0 you can also apply pathch win.path
|
|
|
which you can found in installg4/install/MSVC/ directory.
|
|
|
-->
|
|
|
[[_TOC_]]
|
|
|
|
|
|
Hire the instructions for native Geant4 installation with the Visual Studio C++ compiler on Windows.
|
... | ... | @@ -14,7 +10,7 @@ Hire the instructions for native Geant4 installation with the Visual Studio C++ |
|
|
* Windows 10 or 11
|
|
|
* Microsoft Visual Studio C++ compiler
|
|
|
|
|
|
The installation tested with Windows 11 MSVC 2022 (v17.13.5) and Qt 5.12.2
|
|
|
The installation tested with Windows 11 MSVC 2022 (v17.13.6) and Qt 5.12.2
|
|
|
|
|
|
## Development Environment
|
|
|
|
... | ... | @@ -34,7 +30,7 @@ was necessarily to compile Geant4. |
|
|
### CMake for Windows
|
|
|
|
|
|
The Visual Studio come with cmake program but without CMake GUI.
|
|
|
We use this cmake for compilation and installing Geant4.
|
|
|
We use this cmake from Visual Studio for compilation and installing Geant4.
|
|
|
|
|
|
You can download and install latest version directly from
|
|
|
https://cmake.org/download/ or use package installers like
|
... | ... | @@ -84,11 +80,11 @@ Visual Studio. |
|
|
I use following commands:
|
|
|
|
|
|
```
|
|
|
7z x xerces-c-3.2.3.zip
|
|
|
7z x xerces-c-3.2.5.zip
|
|
|
mkdir xerces-c-build
|
|
|
cd xerces-c-build
|
|
|
|
|
|
cmake -DCMAKE_INSTALL_PREFIX=D:\Xerces-C ..\xerces-c-3.2.3
|
|
|
cmake -DCMAKE_INSTALL_PREFIX=D:\Xerces-C ..\xerces-c-3.2.5
|
|
|
cmake --build . --config RelWithDebInfo --parallel
|
|
|
ctest -V -C RelWithDebInfo -j 4
|
|
|
cmake --build . --config RelWithDebInfo --parallel --target install
|
... | ... | @@ -199,8 +195,6 @@ cmake --build . --config RelWithDebInfo --target install --parallel 8 |
|
|
|
|
|
### 1. Open new DOS Prompt window
|
|
|
|
|
|
- You can use "x86 Native Tools Command Promt for VS 2022" and setup Qt
|
|
|
environment via command `call <QT_INSTALL_DIR\msvc2019_64\bin\qtenv2.bat`
|
|
|
|
|
|
### 2. Setup environment
|
|
|
|
... | ... | @@ -209,6 +203,10 @@ setup for compiler and Qt5 in dos prompt, usage: |
|
|
|
|
|
`call setup_env.bat`
|
|
|
|
|
|
> Alternativly ou can use "x86 Native Tools Command Promt for VS 2022"
|
|
|
> and setup Qt environment via command
|
|
|
> `call <QT_INSTALL_DIR\msvc2019_64\bin\qtenv2.bat`
|
|
|
|
|
|
### 3. Test Geant4 installation
|
|
|
|
|
|
Setup Geant4 environment:
|
... | ... | @@ -216,27 +214,33 @@ Setup Geant4 environment: |
|
|
call d:\Geant4\dev\bin\geant4.bat
|
|
|
```
|
|
|
|
|
|
cmake search path for Xerces-C must set or give to cmake as -D parameter
|
|
|
|
|
|
```
|
|
|
set CMAKE_PREFIX_PATH=D:\Xerces-C
|
|
|
``
|
|
|
|
|
|
Try to compile B1 example
|
|
|
```
|
|
|
mkdir B1-Build
|
|
|
cd B1-Build
|
|
|
cmake d:\Geant4\dev\share\Geant4\examples\basic\B1
|
|
|
cmake d:\Geant4\11.3.1\share\Geant4\examples\basic\B1
|
|
|
```
|
|
|
You will see the output like this:
|
|
|
|
|
|
```
|
|
|
-- Building for: Visual Studio 17 2022
|
|
|
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19045.
|
|
|
-- The C compiler identification is MSVC 19.35.32217.1
|
|
|
-- The CXX compiler identification is MSVC 19.35.32217.1
|
|
|
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.26100.
|
|
|
-- The C compiler identification is MSVC 19.43.34810.0
|
|
|
-- The CXX compiler identification is MSVC 19.43.34810.0
|
|
|
-- Detecting C compiler ABI info
|
|
|
-- Detecting C compiler ABI info - done
|
|
|
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.35.32215/bin/Hostx64/x64/cl.exe - skipped
|
|
|
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x64/cl.exe - skipped
|
|
|
-- Detecting C compile features
|
|
|
-- Detecting C compile features - done
|
|
|
-- Detecting CXX compiler ABI info
|
|
|
-- Detecting CXX compiler ABI info - done
|
|
|
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.35.32215/bin/Hostx64/x64/cl.exe - skipped
|
|
|
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x64/cl.exe - skipped
|
|
|
-- Detecting CXX compile features
|
|
|
-- Detecting CXX compile features - done
|
|
|
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
|
... | ... | @@ -246,29 +250,45 @@ You will see the output like this: |
|
|
-- Looking for pthread_create in pthread
|
|
|
-- Looking for pthread_create in pthread - not found
|
|
|
-- Found Threads: TRUE
|
|
|
-- Found XercesC: D:/Xerces-C/lib/xerces-c_3.lib (found suitable version "3.2.3", minimum required is "3.2.3")
|
|
|
-- Found XercesC: D:/Xerces-C/lib/xerces-c_3.lib (found suitable version "3.3.0", minimum required is "3.3.0")
|
|
|
-- Found OpenGL: opengl32
|
|
|
-- Found Geant4: D:/Geant4/11.1.1/lib/cmake/Geant4/Geant4Config.cmake (found version "11.1.1")
|
|
|
-- Configuring done
|
|
|
-- Generating done
|
|
|
-- Build files have been written to: D:/workspace/GEANT4/B1-build
|
|
|
-- Found Geant4: D:/Geant4/11.3.1/lib/cmake/Geant4/Geant4Config.cmake (found version "11.3.1")
|
|
|
-- Configuring done (14.3s)
|
|
|
-- Generating done (0.1s)
|
|
|
-- Build files have been written to: ... /B1-build
|
|
|
```
|
|
|
Now we can build and run example.
|
|
|
|
|
|
The build step:
|
|
|
|
|
|
```cmake --build . --config RelWithDebInfo --parallel 4```
|
|
|
```cmake --build . --config RelWithDebInfo --parallel 8
|
|
|
|
|
|
Version MSBuild 17.13.19+0d9f5a35a pour .NET Framework
|
|
|
|
|
|
1>Checking Build System
|
|
|
Building Custom Rule D:/Geant4/11.3.1/share/Geant4/examples/basic/B1/CMakeLists.txt
|
|
|
exampleB1.cc
|
|
|
ActionInitialization.cc
|
|
|
DetectorConstruction.cc
|
|
|
EventAction.cc
|
|
|
PrimaryGeneratorAction.cc
|
|
|
RunAction.cc
|
|
|
SteppingAction.cc
|
|
|
Génération de code en cours...
|
|
|
exampleB1.vcxproj -> D:\workspace\GEANT4\installg4\install\MSVC\B1-build\RelWithDebInfo\exampleB1.exe
|
|
|
Building Custom Rule D:/Geant4/11.3.1/share/Geant4/examples/basic/B1/CMakeLists.txt
|
|
|
|
|
|
```
|
|
|
|
|
|
To run exaple use command:
|
|
|
|
|
|
```RelWithDebInfo\exampleB1.exe run1.mac```
|
|
|
```RelWithDebInfo\exampleB1.exe exampleB1.in```
|
|
|
|
|
|
You will see the output like below:
|
|
|
|
|
|
```
|
|
|
|
|
|
**************************************************************
|
|
|
Geant4 version Name: geant4-11-01-ref-04 [MT] (30-April-2023)
|
|
|
Geant4 version Name: geant4-11-03-patch-01 [MT] (21-March-2025)
|
|
|
<< in Multi-threaded mode >>
|
|
|
Copyright : Geant4 Collaboration
|
|
|
References : NIM A 506 (2003), 250-303
|
... | ... | @@ -276,26 +296,19 @@ You will see the output like below: |
|
|
: NIM A 835 (2016), 186-225
|
|
|
WWW : http://geant4.org/
|
|
|
**************************************************************
|
|
|
|
|
|
<<< Reference Physics List QBBC
|
|
|
...
|
|
|
<snip>
|
|
|
...
|
|
|
|
|
|
================== Deleting memory pools ===================
|
|
|
Pool ID 'class G4NavigationLevelRep', size : 0.00288 MB
|
|
|
Pool ID 'class G4ReferenceCountedHandle<void>', size : 0.000961 MB
|
|
|
Pool ID 'class G4DynamicParticle', size : 0.000961 MB
|
|
|
Pool ID 'class G4SmartVoxelNode', size : 0.000961 MB
|
|
|
Pool ID 'class G4SmartVoxelProxy', size : 0.000961 MB
|
|
|
Pool ID 'class G4CountedObject<void>', size : 0.000961 MB
|
|
|
Number of memory pools allocated: 6; of which, static: 0
|
|
|
Dynamic pools deleted: 6 / Total memory freed: 0.0077 MB
|
|
|
============================================================
|
|
|
G4Allocator objects are deleted.
|
|
|
UImanager deleted.
|
|
|
StateManager deleted.
|
|
|
RunManagerKernel is deleted. Good bye :)
|
|
|
RunManager is deleted.
|
|
|
--------------------End of Global Run-----------------------
|
|
|
The run consists of 1000
|
|
|
Cumulated dose per run, in scoring volume : 5.38591 nanoGy rms = 144.936 picoGy
|
|
|
------------------------------------------------------------
|
|
|
|
|
|
Graphics systems deleted.
|
|
|
Visualization Manager deleting...
|
|
|
```
|
|
|
|
|
|
Check you have no crash and errors in aoutput.
|
... | ... | @@ -307,8 +320,6 @@ http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/InstallationGuide/h |
|
|
|
|
|
### 4. Test ROOT Installation
|
|
|
|
|
|
Example of root v6.26/02.
|
|
|
|
|
|
Setup root environment if not yet done:
|
|
|
|
|
|
```
|
... | ... | @@ -320,12 +331,12 @@ Start the ROOT interactive session: |
|
|
```
|
|
|
D:\workspace>root
|
|
|
------------------------------------------------------------------
|
|
|
| Welcome to ROOT 6.26/02 https://root.cern |
|
|
|
| (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
|
|
|
| Built for win64 on Apr 12 2022, 16:28:03 |
|
|
|
| From tags/v6-26-02@v6-26-02 |
|
|
|
| With MSVC 19.31.31104.0 |
|
|
|
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
|
|
|
| Welcome to ROOT 6.34.06 https://root.cern |
|
|
|
| (c) 1995-2024, The ROOT Team; conception: R. Brun, F. Rademakers |
|
|
|
| Built for win64 on Mar 27 2025, 04:54:19 |
|
|
|
| From tags/v6-34-06@v6-34-06 |
|
|
|
| With MSVC 19.39.33521.0 |
|
|
|
| Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
|
|
|
------------------------------------------------------------------
|
|
|
|
|
|
root [0]
|
... | ... | |