Creating a Standalone Executable from Geant4 for Use on Computers Without Geant4 Installed

Hello,

I am exploring ways to create a standalone executable from Geant4 that can be executed on computers where Geant4 is not installed. My current understanding is that following the most examples leads to dynamic linking, but I am interested in finding out how to convert this into static linking, or if there are better methods to create a standalone executable.

Moreover, I am curious if it’s possible to only transfer and link the cross-section data library to a computer without Geant4 installed, and how this linkage can be achieved.

I have looked into the extended/visualization/standalone example, but it doesn’t seem to fit the requirements I am looking for. Are there any appropriate examples or guidance available that could help me with this process?

Any advice or pointers on how to achieve this would be greatly appreciated. Thank you in advance for your time and help.

The Installation Guide has a section on “advanced” build options, which includes building G4 static libraries instead of shared. You can certainly copy over just the datasets you need. You’ll have to put them into a matching directory structure, of course, and have a setup script that sets the necessary envvars (if you’re not installing G4, you won’t have G4’s own script to use, so you get to write it yourself).

However, all of that assumes that your destination system has exactly the same operating system, and installed system libraries, as your build. A potentially simpler solution would be to build your Geant4 installation and your application inside a Docker or Singularity (Apptainer) container, and copy that over to your standalone machine instead.

Thank you for your response.

I am considering users with limited computer skills, and thus, using Docker or Singularity might be challenging for them. Therefore, I’ve decided to proceed with the static library method, and following your advice, it seems to work well when Geant4 is installed alongside it.

However, I only use QBBC and RadioactiveDecay physics in my application, and I believe that not all datasets are necessary to transfer. Is there a way to determine which datasets are essential for running my project? The names like QBBC and EMStandardPhysics do not directly correspond to dataset names, e.g. G4ABLA, G4EMLOW, so I’m unsure how to connect them correctly.

Could you provide any guidance or resources on identifying and linking the required datasets?