Creating a User application with Geant4

Hi all,

I’m very new to using Geant4 and I have been going through the manual Geant4 User’s Guide for Application Development. While I understand some of what’s being said, I’m still quite lost by the entire construction process of a Geant4 application.

I get that to create an application there needs to be a “main.cc” file that will be executed and then user-defined headers and sources that go along with the main file. However, how does one go about compiling everything? Do we need a “Cmakelists.txt” file or can we write just a “Makefile” to generate the application?

I’m using a mac with macOS Mojave version 10.14.5. I have the visualization drivers installed as well as a binary version of G4Beamline.

Any help would be appreciated and thank you for your time!

Cheers,
Jason

Dear Jason,

CMake is a build tool that is very convenient to use, and it will generate a Makefile for you. There is of course no obligation to use it, but it is recommended, and if you have a look at one of the example CMakeLists.txt, you will see that it simplifies greatly the process of writing your application. Maybe in addition to consulting the Application Development guide, you can also have a look at the chapter from the Installation Guide.

I hope it helps.
Cheers,
Anna

Hi Anna,

Thanks for your help! I tried to write my own Makefile but when I tried to compile it, I got some unknown architecture errors. I’ll give the CMake approach a shot and I’ll take a look at the chapter.

Thanks again!
Cheers,
Jason

Dear Jason,

Please take a look at the Geant4 basic examples, which are distributed with Geant4 source code. This will give you a good idea how to write a also build a Geant4 application.

Besides the Installation Guide, you can also take a look at the examples documentation web page:
http://geant4-userdoc.web.cern.ch/geant4-userdoc/Doxygen/examples_doc/html/index.html

where we also give short instructions how to build an example. Follow the link “How to build and run an example”.

Best regards,

Ivana