Error while compiling

I have been trying to accumulate hits and retrieve physical information using the sensitive detector. I have referred to example B2 from Geant4 and made TrackerHit, TrackerSD, and updated DetectorConstruction with a Sensitive detector. It compiles 100% but still gives the following error.

[100%] Linking CXX executable example1
CMakeFiles/example1.dir/src/TrackerHit.cc.o: In function `TrackerHit::TrackerHit()':
TrackerHit.cc:(.text+0xa0): undefined reference to `vtable for TrackerHit'
CMakeFiles/example1.dir/src/TrackerHit.cc.o: In function `G4Allocator<TrackerHit>::G4Allocator()':
TrackerHit.cc:(.text._ZN11G4AllocatorI14TrackerHitEC2Ev[_ZN11G4AllocatorI14TrackerHitEC5Ev]+0x24): undefined reference to `typeinfo for TrackerHit'
CMakeFiles/example1.dir/src/TrackerSD.cc.o: In function `TrackerSD::TrackerSD(G4String, G4String)':
TrackerSD.cc:(.text+0x2da): undefined reference to `TrackerSDMessenger::TrackerSDMessenger(TrackerSD*)'
collect2: error: ld returned 1 exit status
make[2]: *** [example1] Error 1
make[1]: *** [CMakeFiles/example1.dir/all] Error 2
make: *** [all] Error 2

Could you please help me troubleshoot this ?

Without seeing the code it’s always a bit difficult to debug, but link time errors like this usually indicate a file is missing from the build, or that a member function has been declared but not defined. For example:

would tend to indicate that either the file containing the definition of TrackerSDMessenger::TrackerSDMessenger(TrackerSD*) has not been compiled, or the definition isn’t present at all.

Don’t forget that with compile/link errors, places like StackOverflow and Google can be incredibly useful first ports of call to search for solutions. I am not doing a “Let me Google that for you” here, just highlighting an incredibly useful resource that may well help solve issues like the above in future more quickly than this forum can. In fact that’s exactly what I did to remind myself of the undefined reference to vtable error: undefined reference to vtable - Google Suche