Geant4 Installation Windows 10

0 views
Skip to first unread message

Shari Alvine

unread,
Aug 4, 2024, 9:57:26 PM8/4/24
to viaracirmi
notesI am using cmake 3.18.2, visual studio 2019 so everything should work properly right. Install and build apparently worked. I can also build example B1 with no problem. This issue appears when I run the executable generated by the example. I traced the issue to the post installation guide in this post, but I believe I did everything correctly in the post install guide for windows (Im probably wrong if not it would be working). Can someone please help me with the post-installation setup or if you ran into this same problem?

Thank you so much for helping me! Any more detailed information you may need to better understand my problem let me know, I am getting frustrated with getting stuck and not finding answers to this problem as I followed line by line the installation guide. Thank you so much again!


and so on for the remainder. If your environment variables for the data are pointing the to directory names, e.g. G4ABLADATA is set to C:\Geant4\geant4_10_06-install\share\Geant4-10.6.2\data\G4ABLA3.1, then things should then work. If the variable values include the .tar or .tar.gz extension, simply remove them from the value.


To compile and use Geant4 under windows some additional tools are required. First you need Microsoft Visual Studio version 6 (with service pack 5 or later). This is commercial software that you will need to purchase and install. When installing Visual Studio you will be asked whether you want to allow it to modify your environment variables. I find it best to answer No to this question, and instead set the variables in my cygwin startup script (see below).


Secondly you will need to install cygwin, a Unix emulation layer for windows. The cygwin software is freely available from It can be quite tricky to install the correct components of the cygwin toolkit, but Norman Graf has writtendetailed installation instructions which are included on this CD. I find the easiest way to set up visual studio to run under cygwin is to modify my cygwin.bat file (normally in c:\cygwin) as follows:


Finally you will need to install CLHEP. CLHEP is available on this CDhere. (CLHEP is distributed as a .tgz file, you will need a tool likeWinZip to unpack it). I assume in the following that you have unpacked CLHEP into c:\clhep.


Now you are ready to unpack and install Geant4. Geant4 is available on this CD here. (Geant4 is distributed as a .zip file, you will need a tool likeWinZip to unpack it). I assume in the following that you have unpacked CLHEP into c:\geant4\geant4_5_2_p02.


To compile and run Geant4 you will need to set several environment variables. I find the easiest way to do this is to create a simple script. My script (which I save in c:\geant4\geant4_5_2_p02\geant4-setup.sh) contains:


i have a big problem when installing geant4 in windows 7 64 bit with vs2010 and geant4 4.10With cmake everything goes fine but then when it come to build the INSTALL packagese in the Geant4.sln when it comes to about the 3000 line it throws an error:


Open the Microsoft Store and search for Ubuntu. Be sure to install the latest version (by now the last one is Ubuntu 20.04) by clicking, first on Get and then on Install. Follow the instructions and create a username with a password, which will be your account for the WSL.


It may not work for two reasons: gunzip is not installed (which you can solve by hitting sudo apt install gunzip) or because you did not use the super user command, so repeat the previous command putting at the top of the line sudo.


Usually you will obtain a folder named geant, but sometimes it can have the full name, so something like geant4.10.07.p02. Be sure to check with an ls command because the last part of the installation process will need the name of the folder.


Now we are going to compile the source code into the Geant4 libraries, so we can start creating two directories: one for the code building instructions, that will be named geant4-build, and one where Geant4 will be installed, called Geant4.


Still regarding G4, I installed qt5 on Ubuntu and when I run the macro to initialize the visualization, the GUI window opens and I can see the axis, but I cannot see the geometry. Have you faced anything similar?


In this first hands on you will learn: How to install Geant4 and some of the most common options How to compile an application against an installed version of Geant4 Run an application and interact with Geant4.There is no additional exercise tar-ball for this first hands onsince we use Geant4 code base.

We are going to use Geant4 Version 10.0.p01 (Geant4 version numbersare expressed with the triplet of numbers: Major.Minor.PatchLevel).

Youshould have already installed Geant4 on your machine, however wereview here some options and give some details. Geant4 code can bedownloaded from download are on Geant4 website:


During the next days we will develop a Geant4 application that willuse Geant4 installed libraries. Geant4 is a toolkit, thus a Geant4 instllation consists of a set of librariesand headers files (plus resource files: the data-base data, andexemples source code). You can create an application that is compiled against aGeant4 installation.




With its basic installation Geant4 Version 10.0 series does nothave external dependicies, but to configure the installation processcmake is needed. The role of cmake is to automatically createMakfiles (or project files for IDEs) from a set of configurableoptions. We will show how to use cmake via command line options, but amenu-based version of cmake exists (type ccmake instad ofcmake) and for some platforms also a GUI is avialble(cmake-gui). Geant4 Version 10.0 requires cmake version 2.6.4or more recent.


In the following we will also describe how tosetup and use the interactive graphical user interface (GUI) based onQt. This is an optionalcomponent. We use Qt version 4 (Geant4 supportsQt version 5 only experimentally). Many Linux distributions alreadycome with Qt4 installed. It is relatively easy tomanually install Qt4 on a Linux or Mac system, but we will not coverthis step in this tutorial. This component is optional, ifyou do not want to use Qt simply skip the Qt options duringconfiguration. None of exercises requires GUI interfaces to be completed.


Geant4 Version 10.0 introduces event level parallelism viamulti-threading. This means that we will develop a parallel applicationthat will simulate events using all available cores of your machine. This is an optional component: we will show here how to turn iton, but if you do not want to enable MT you can still follow the exercisesas they are, since the code is also compatible with the sequentialversion of Geant4. To enable MT you need a recent compiler (on Linuxwe recommend at least gcc 4.2, on Mac OS X you need clang at leastversion 3.0, sorry no WIN support yet).

Note for virtual machine users: if you are using a VM for thistutorial, even if you have a multi-core laptop it is probable that theVM sees only one CPU core. It is usually just a matter of VMconfiguration to allow more than one CPU in the guest OS.


After downloading and un-packing Geant4 tarball(geant4.10.00.p01.tar.gz) in an empty workingdirectory, we need tocreate a build directory where the compilation of Geant4 isperformed: cmake uses out of source builds.


If everything works as expected cmake will workfew seconds producing some output, the last lines should read:



-- Configuring done

-- Generating done

-- Build files have been written to: /build


If you do not want to use Qt, remove the-DGEANT4_USE_QT=ON option. If you do not wantmulti-threaded support remove also the corresponding option.

If you disable Qt it is recommended to enable OpenGL with:-DGEANT4_USE_OPENGL_X11=ON. If neither Qt or OpenGL work for youcontact us.


Some notes: Refer to the installation manual for a complete list of installation options. If you already have installed Geant4 databases somewhere in your system, you can avoid downloading automatically the library by replacing -DGEANT4_INSTALL_DATA=ON to -DGEANT4_INSTALL_DATADIR=where-the-dbs-are. If you receive an error about EXPAT libaries, add -DGEANT4_USE_SYSTEM_EXPAT=OFF. If you want to use an already installed version of CLHEP, instead of the Geant4 internal one, you can specify that via the option: -DGEANT4_USE_SYSTEM_CLHEP=OFF. You may need to specify where to find CLHEP (see installation manuals). If you want to use an IDE you can specify the option -G (run cmake without options to see a list of supported IDEs on your system, for example on Mac OS X with Xcode: cmake -GXcode [...], for KDevelop3 support: -GKDevelop3. In such a case instead of makefiles cmake will create project files for that IDE.


The include directory contains a sub-directory(Geant4) where all the .hh files arelocated. The directory lib[64] contains all Geant4libraries and a sub-directory: Geant4-10.0.1 thatcontains cmake files specific to Geant4 (they are used to compile anapplication via cmake that uses Geant4).


Step 3: Setup runtime environemnt

Every time you want to use or compile an application using Geant4remember to (select appropriate script extension depending on your shell type):

$ source /bin/geant4.[c]sh

For this tutorial you will need to do this step evry time a newterminal window isopen.


Example code can be found under:geant4-soruce-dir/examples/basic/B1. This is anapplication that needs Geant4 libraries and headers to be compiledcorrectly, thus you will need to instruct cmake touse Geant4 from the location where you have installed it. Do notcompile the example in the same build directory where you compiledGeant4, create a new clean one (use a clean directoryfor each exercise of this tutorial).

3a8082e126
Reply all
Reply to author
Forward
0 new messages