Compilation Error in Geant4 B1 Example

Geant4 Version: 11.2.1
Operating System: Ubuntu 22.04.4 LTS
Conda Version: 23.9.0
CMake Version: 3.26.3

Hello,

I’m encountering a compilation error while trying to build the Geant4 B1 example. Here’s the error message I’m receiving:

(G4-Ayoub) mlahdour@ThinkCentre:~/Bureau/Ayoub/software/geant4-v11.2.1-install/share/Geant4/examples/basic/B1/build$ make
[ 12%] Building CXX object CMakeFiles/exampleB1.dir/exampleB1.cc.o
/home/mlahdour/Bureau/Ayoub/software/geant4-v11.2.1-install/share/Geant4/examples/basic/B1/exampleB1.cc: In function ‘int main(int, char**)’:
/home/mlahdour/Bureau/Ayoub/software/geant4-v11.2.1-install/share/Geant4/examples/basic/B1/exampleB1.cc:80:50: error: no matching function for call to ‘G4VisExecutive::G4VisExecutive(int&, char**&)’
   80 |   auto visManager = new G4VisExecutive(argc, argv);
      |                                                  ^
In file included from /usr/local/include/Geant4/G4VisExecutive.hh:132,
                 from /home/mlahdour/Bureau/Ayoub/software/geant4-v11.2.1-install/share/Geant4/examples/basic/B1/exampleB1.cc:38:
/usr/local/include/Geant4/G4VisExecutive.icc:126:1: note: candidate: ‘G4VisExecutive::G4VisExecutive(const G4String&)’
  126 | G4VisExecutive::G4VisExecutive (const G4String& verbosityString):
      | ^~~~~~
/usr/local/include/Geant4/G4VisExecutive.icc:126:1: note:   candidate expects 1 argument, 2 provided
/home/mlahdour/Bureau/Ayoub/software/geant4-v11.2.1-install/share/Geant4/examples/basic/B1/exampleB1.cc:111:10: error: type ‘<type error>’ argument given to ‘delete’, expected pointer
  111 |   delete visManager;
      |          ^~~~
make[2]: * [CMakeFiles/exampleB1.dir/build.make:76 : CMakeFiles/exampleB1.dir/exampleB1.cc.o] Erreur 1
make[1]: * [CMakeFiles/Makefile2:84 : CMakeFiles/exampleB1.dir/all] Erreur 2
make: * [Makefile:136 : all] Erreur 2

  • I’ve created a new Conda environment specifically for this version to avoid conflicts with the older version 11.1.2.

Thank you,

Hi

First, when supplying code or output, please use triple-back-accent (``` on a separate line), then the code/output, terminated by another ```. Or an attachment. Not an screenshot.

Mmm. Seems you are using an old version of G4VisExecutive.icc. Do you have your own copy? Should not be needed. In your main program file:

#include "G4VisExecutive.hh"

should be enough. It includes G4VisExecutive.icc from the geant4 source tree.

At least, that’s how it looks. Let us know if this is a misdiagnosis.

John

Thank you for your remark, John. Yes, indeed, "G4VisExecutive.hh" is included in the main file.

/// \file exampleB2b.cc
/// \brief Main program of the B2b example

#include "DetectorConstruction.hh"
#include "ActionInitialization.hh"

#include "G4RunManagerFactory.hh"
#include "G4SteppingVerbose.hh"
#include "G4UImanager.hh"
#include "FTFP_BERT.hh"
#include "G4StepLimiterPhysics.hh"

#include "Randomize.hh"

#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

int main(int argc,char** argv)
{ 

Additionally, I’ve tested with another extended example (Hadr04). Here’s the output:

(G4-Ayoub) mlahdour@ThinkCentre:~/Bureau/Ayoub/software/geant4-v11.2.1-install/share/Geant4/examples/extended/hadronic/Hadr04/build$ ./Hadr04 
Available UI session types: [ tcsh, csh ]

**********************
 Geant4 version Name: geant4-11-01-patch-02 [MT]   (15-June-2023)
  << in Multi-threaded mode >> 
                       Copyright : Geant4 Collaboration
                      References : NIM A 506 (2003), 250-303
                                 : IEEE-TNS 53 (2006), 270-278
                                 : NIM A 835 (2016), 186-225
                             WWW : http://geant4.org/
**********************

Visualization Manager instantiating with verbosity "warnings (3)"...
Visualization Manager initialising...
Registering graphics systems...

You have successfully registered the following graphics systems.
Registered graphics systems are:
  ASCIITree (ATree)
  DAWNFILE (DAWNFILE)
  G4HepRepFile (HepRepFile)
  RayTracer (RayTracer)
  VRML2FILE (VRML2FILE)
  gMocrenFile (gMocrenFile)
  TOOLSSG_OFFSCREEN (TSG_OFFSCREEN)
  TOOLSSG_OFFSCREEN (TSG_OFFSCREEN, TSG_FILE)

Registering model factories...

You have successfully registered the following model factories.
Registered model factories:
  generic
  drawByAttribute
  drawByCharge
  drawByOriginVolume
  drawByParticleID
  drawByEncounteredVolume

Registered models:
  None

Registered filter factories:
  attributeFilter
  chargeFilter
  originVolumeFilter
  particleFilter
  encounteredVolumeFilter

Registered filters:
  None

You have successfully registered the following user vis actions.
Run Duration User Vis Actions: none
End of Event User Vis Actions: none
End of Run User Vis Actions: none

Some /vis commands (optionally) take a string to specify colour.
"/vis/list" to see available colours.
PreInit>   

when I run cmake …, it indicates that Geant4 version 11.1.2 is found, even though I’m working with version 11.2.1.

(base) mlahdour@ThinkCentre:~/Bureau/Ayoub/software/geant4-v11.2.1-install/share/Geant4/examples/basic/B3/B3a/build$ cmake ..
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - 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: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found EXPAT: /usr/lib/x86_64-linux-gnu/libexpat.so (found suitable version "2.4.7", minimum required is "2.4.7") 
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found Geant4: /usr/local/lib/cmake/Geant4/Geant4Config.cmake (found version "11.1.2") 
-- Configuring done (0.3s)
-- Generating done (0.0s)
-- Build files have been written to: /home/mlahdour/Bureau/Ayoub/software/geant4-v11.2.1-install/share/Geant4/examples/basic/B3/B3a/build

Hi Ayoub

That certainly explains it. Of course, one must compile and link with the correct Geant4 code and libraries. Do you know how to do this? Can you correct the above problem yourself? (Have a look at the Installation Guide.) Let us know if it fixes things for you.

John

Hi John,

Thanks for your reply and clarification! You’re absolutely right, I needed to link the libraries.

I was able to fix it by running . geant4make.sh within the following path :

/path/to/geant4-v11.0.0-install/geant4.sh

Ayoub

Hi Ayoub

That’s great. Thanks for letting us know.

John

1 Like