Hello, I am a beginner trying to learn Geant4.
I have the following error, don’t quite understand why. Can someone please help?
/usr/bin/ld: CMakeFiles/sim.dir/construction.cc.o: in function MyDetectorConstruction::ConstructSDandField()': construction.cc:(.text+0x1307): undefined reference to
MySensitiveDetector::MySensitiveDetector(G4String)’
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/sim.dir/build.make:189: sim] Error 1
make[1]: *** [CMakeFiles/Makefile2:104: CMakeFiles/sim.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
Relevant part of code in contruction.cc
void MyDetectorConstruction::ConstructSDandField()
{
MySensitiveDetector *sensDet = new MySensitiveDetector("SensitiveDetector");
logicDetector->SetSensitiveDetector(sensDet);
}
Here is the header file contruction.hh:
#ifndef CONSTRUCTION_HH
#define CONSTRUCTION_HH
#include "G4SystemOfUnits.hh"
#include "G4VUserDetectorConstruction.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4Box.hh"
#include "G4PVPlacement.hh"
#include "G4NistManager.hh"
#include "detector.hh"
class MyDetectorConstruction : public G4VUserDetectorConstruction
{
public:
MyDetectorConstruction();
~MyDetectorConstruction();
virtual G4VPhysicalVolume *Construct();
private:
G4LogicalVolume *logicDetector;
virtual void ConstructSDandField();
};
#endif