Message: Re: Is it possible to build a simulation so that it is portable? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Note Re: Is it possible to build a simulation so that it is portable? 

Forum: Installation and Configuration
Re: Question Is it possible to build a simulation so that it is portable? (Adam)
Date: 10 May, 2016
From: Ben Morgan <Ben Morgan>

On Thu, 05 May 2016 20:25:09 GMT, Adam wrote:
> I would like to build my executable so that it may be ran on systems
> without an installation of Geant4. Is it possible to bundle all of the
> required libraries with the executable instead of linking against them?
> 

There is nothing directly in Geant4 to do this, but CMake does provide some functionality to assist in creating bundles, depending on the platform you are running on. See the BundleUtilities module for a starting point. Though it's mostly more OSX-style .app bundles, it can be used on other systems.

At least for the Geant4 libraries, these can be linked statically to the application and this will typically result in a smaller bundle (depending on what physics processes the application uses). To link an application to static Geant4 libraries rather than dynamic, ensure the install of Geant4 is done with the cmake argument BUILD_STATIC_LIBS enabled. When building the application with cmake, add the static component to the list of features needed in the call to find_package:

find_package(Geant4 REQUIRED static)

add_executable(foo foo.cc)
target_link_libraries(foo ${Geant4_LIBRARIES})

Here, the addition of the static argument ensures that the Geant4_LIBRARIES variable is populated with static rather than dynamic arguments.

Other than binary libraries, any data libraries (G4EMLOW etc) required by physics processes used by the applications will need bundling as well. Because Geant4 currently uses environment variables to point the code to the locations of these files, a bundled application will need to provide a mechanism to automatically set these variables. That can be done using, for example, a wrapper shell/python script which sets the needed variables before running the bundled application. Another way would be to make the executable self-locating, and use calls to the setenv or similar C functions to set the processes environment before creating any Geant4 objects.

 Add Message Add Message
to: "Re: Is it possible to build a simulation so that it is portable?"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]