Geant4 compilation error 'Undefined reference to'

I am using the Geant4 toolkit with low energy EM package. I am making some changes to an already written code. First I was using the standard package and there was no compilation error, after changing the model I am getting the error ‘undefined reference to’.
What are your suggestions to resolve the error?

[ 9%] Linking CXX executable cyliSD
CMakeFiles/cyliSD.dir/src/ExN01PhysicsList.cc.o: In function ExN01PhysicsList::ConstructEM()': ExN01PhysicsList.cc:(.text+0x32a): undefined reference to G4LowEnergyCompton::G4LowEnergyCompton(G4String const&)’
ExN01PhysicsList.cc:(.text+0x379): undefined reference to G4LowEnergyPhotoElectric::G4LowEnergyPhotoElectric(G4String const&)' ExN01PhysicsList.cc:(.text+0x3ae): undefined reference to G4LowEnergyPhotoElectric::ActivateAuger(bool)’
ExN01PhysicsList.cc:(.text+0x3da): undefined reference to G4LowEnergyPhotoElectric::SetCutForLowEnSecPhotons(double)' ExN01PhysicsList.cc:(.text+0x406): undefined reference to G4LowEnergyPhotoElectric::SetCutForLowEnSecElectrons(double)’
ExN01PhysicsList.cc:(.text+0x457): undefined reference to G4LowEnergyRayleigh::G4LowEnergyRayleigh(G4String const&)' ExN01PhysicsList.cc:(.text+0x520): undefined reference to G4LowEnergyIonisation::G4LowEnergyIonisation(G4String const&)’
ExN01PhysicsList.cc:(.text+0x54f): undefined reference to G4LowEnergyIonisation::ActivateAuger(bool)' ExN01PhysicsList.cc:(.text+0x578): undefined reference to G4LowEnergyIonisation::SetCutForLowEnSecPhotons(double)’
ExN01PhysicsList.cc:(.text+0x5a1): undefined reference to G4LowEnergyIonisation::SetCutForLowEnSecElectrons(double)' ExN01PhysicsList.cc:(.text+0x5f7): undefined reference to G4LowEnergyBremsstrahlung::G4LowEnergyBremsstrahlung(G4String const&)’
ExN01PhysicsList.cc:(.text+0x920): undefined reference to G4hLowEnergyIonisation::G4hLowEnergyIonisation(G4String const&)' ExN01PhysicsList.cc:(.text+0xa64): undefined reference to G4hLowEnergyIonisation::G4hLowEnergyIonisation(G4String const&)’
collect2: error: ld returned 1 exit status
CMakeFiles/cyliSD.dir/build.make:370: recipe for target ‘cyliSD’ failed
make[2]: *** [cyliSD] Error 1
CMakeFiles/Makefile2:99: recipe for target ‘CMakeFiles/cyliSD.dir/all’ failed
make[1]: *** [CMakeFiles/cyliSD.dir/all] Error 2
Makefile:129: recipe for target ‘all’ failed
make: *** [all] Error 2

Thanks in advance

It appears that your code was based on copying and modifying the “eRosita” advanced example. If those classes (like G4LowEnergyCompton) are found in your source code, then you have a configuration problem. If not, then you probably need to copy them from the eRosita example in whatever version of Geant4 you’re using.

what type of configuration problem?

Did you set up the Geant4 environment variables as described in the Installation Guide? Are you sure that the class definition files (.hh and .cc) are in the directory of the code you’re trying to compile?

is there need to do something with the environment variables if I just change the package? Yes, I am sure that all class definition files are in the right directory.

As Mike noted, check that the files with the G4LowEnergyCompton class declaration/definition (and for the other missing refs) are copied into your project. They also need to be added to the appropriate target in the CMakeLists.txt script(s) for the project so that they are actually compiled and linked.

Hello,

please, have a look into another examples, which may be useful to start your application. I mean examples/extended/electromagnetic. For example, a simple one $G4INSTALL/examples/extended/electromagnetic/TestEm8 includes all basic capabilities of recent Geant4 - multi-threading, cuts per region, and g4tool for analysis.

VI

Dear Morgan,

How can I do that?

You will need to edit the CMakeLists.txt file to add the .hh and .cc files to the (I think) cyliSD target defined there (see the CMake manual on add_executable or add_library as appropriate)