Modifying G4PSEnergyDeposit3D primitive scorer: error 'Undefined Reference'

Hi everyone,
I need to detect the kinetic energy of particles passing through a detector. Geant4 provides primitive scorers(PS) as G4PSEnergyDeposit3D, which record the energy deposit but not the kinetic energy of the particle, and I could not find any PS for kinetic energy. So I tried to modify the code of G4PSEnergyDeposit3D(.hh & .cc), by creating header and source files EnergyDepositModified.hh/cc and EnergyDeposit3DModified.hh/cc .
Then as I call call the class EnergyDeposit3DModified to create scorer pointers in the detector construction I get this error : ‘Undefined Reference to EnergyDeposit3DModified::EnergyDeposit3DModified(string, int, int, int)’.
Does any one know why do I get this error?

In addition, whenever I define new header and source files to add a feature to the existing example (e.g. B1) I get the same error ‘Undefined Reference’ to that class.

I would appreciate any suggestion for how to record the kinetic energy.
Thanks to all

Hi, the most likely source of the undefined references you are describing is that you are not actually compiling the .cc files – thus your code sees the declaration of the functions/variables in the header file via the include but the definitions are absent during the linking phase. If you are using a similar setup to your code as all the examples, make sure your header files (.hh) are all in include/ folder and not in a subfolder and make sure all the source files (.cc) are in the src/ directory and not in a subfolder. Once this is assured, re-run cmake from your build directory to ensure CMake updates the Makefiles to include the new cc files and then just run make again

Thanks so much for your response. That was indeed the issue. I needed to re-run CMake to include the source files.