/usr/bin/ld: CMakeFiles/sim.dir/src/construction.cc.o: in function MyDetectorConstruction::MyDetectorConstruction()': construction.cc:(.text+0x0): multiple definition of
MyDetectorConstruction::MyDetectorConstruction()‘; CMakeFiles/sim.dir/src/MyDetectorConstruction.cc.o:MyDetectorConstruction.cc:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/construction.cc.o: in function MyDetectorConstruction::DefineMaterial()': construction.cc:(.text+0x884): multiple definition of
MyDetectorConstruction::DefineMaterial()’; CMakeFiles/sim.dir/src/MyDetectorConstruction.cc.o:MyDetectorConstruction.cc:(.text+0x116): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/construction.cc.o: in function MyDetectorConstruction::MyDetectorConstruction()': construction.cc:(.text+0x0): multiple definition of
MyDetectorConstruction::MyDetectorConstruction()‘; CMakeFiles/sim.dir/src/MyDetectorConstruction.cc.o:MyDetectorConstruction.cc:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/construction.cc.o: in function MyDetectorConstruction::~MyDetectorConstruction()': construction.cc:(.text+0x822): multiple definition of
MyDetectorConstruction::~MyDetectorConstruction()’; CMakeFiles/sim.dir/src/MyDetectorConstruction.cc.o:MyDetectorConstruction.cc:(.text+0xb4): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/construction.cc.o: in function MyDetectorConstruction::~MyDetectorConstruction()': construction.cc:(.text+0x822): multiple definition of
MyDetectorConstruction::~MyDetectorConstruction()‘; CMakeFiles/sim.dir/src/MyDetectorConstruction.cc.o:MyDetectorConstruction.cc:(.text+0xb4): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/construction.cc.o: in function MyDetectorConstruction::~MyDetectorConstruction()': construction.cc:(.text+0x854): multiple definition of
MyDetectorConstruction::~MyDetectorConstruction()’; CMakeFiles/sim.dir/src/MyDetectorConstruction.cc.o:MyDetectorConstruction.cc:(.text+0xe6): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/construction.cc.o: in function MyDetectorConstruction::Construct()': construction.cc:(.text+0x27e0): multiple definition of
MyDetectorConstruction::Construct()‘; CMakeFiles/sim.dir/src/MyDetectorConstruction.cc.o:MyDetectorConstruction.cc:(.text+0xbaa): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/construction.cc.o: in function MyDetectorConstruction::ConstructSDandField()': construction.cc:(.text+0x2b80): multiple definition of
MyDetectorConstruction::ConstructSDandField()’; CMakeFiles/sim.dir/src/MyDetectorConstruction.cc.o:MyDetectorConstruction.cc:(.text+0x1376): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/detector.cc.o: in function MySensitiveDetector::~MySensitiveDetector()': detector.cc:(.text+0xa4): multiple definition of
MySensitiveDetector::~MySensitiveDetector()‘; CMakeFiles/sim.dir/src/MySensitiveDetector.cc.o:MySensitiveDetector.cc:(.text+0x18a): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/detector.cc.o: in function MySensitiveDetector::~MySensitiveDetector()': detector.cc:(.text+0xa4): multiple definition of
MySensitiveDetector::~MySensitiveDetector()’; CMakeFiles/sim.dir/src/MySensitiveDetector.cc.o:MySensitiveDetector.cc:(.text+0x18a): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/detector.cc.o: in function MySensitiveDetector::~MySensitiveDetector()': detector.cc:(.text+0xd6): multiple definition of
MySensitiveDetector::~MySensitiveDetector()‘; CMakeFiles/sim.dir/src/MySensitiveDetector.cc.o:MySensitiveDetector.cc:(.text+0x1ce): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/detector.cc.o: in function MySensitiveDetector::ProcessHits(G4Step*, G4TouchableHistory*)': detector.cc:(.text+0x106): multiple definition of
MySensitiveDetector::ProcessHits(G4Step*, G4TouchableHistory*)’; CMakeFiles/sim.dir/src/MySensitiveDetector.cc.o:MySensitiveDetector.cc:(.text+0x3ba): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/event.cc.o: in function MyEventAction::MyEventAction(MyRunAction*)': event.cc:(.text+0x0): multiple definition of
MyEventAction::MyEventAction(MyRunAction*)‘; CMakeFiles/sim.dir/src/MyEventAction.cc.o:MyEventAction.cc:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/event.cc.o: in function MyEventAction::MyEventAction(MyRunAction*)': event.cc:(.text+0x0): multiple definition of
MyEventAction::MyEventAction(MyRunAction*)’; CMakeFiles/sim.dir/src/MyEventAction.cc.o:MyEventAction.cc:(.text+0x0): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/event.cc.o: in function MyEventAction::~MyEventAction()': event.cc:(.text+0x36): multiple definition of
MyEventAction::~MyEventAction()‘; CMakeFiles/sim.dir/src/MyEventAction.cc.o:MyEventAction.cc:(.text+0x4c): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/event.cc.o: in function MyEventAction::~MyEventAction()': event.cc:(.text+0x36): multiple definition of
MyEventAction::~MyEventAction()’; CMakeFiles/sim.dir/src/MyEventAction.cc.o:MyEventAction.cc:(.text+0x4c): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/event.cc.o: in function MyEventAction::~MyEventAction()': event.cc:(.text+0x68): multiple definition of
MyEventAction::~MyEventAction()‘; CMakeFiles/sim.dir/src/MyEventAction.cc.o:MyEventAction.cc:(.text+0x7e): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/event.cc.o: in function MyEventAction::BeginOfEventAction(G4Event const*)': event.cc:(.text+0x98): multiple definition of
MyEventAction::BeginOfEventAction(G4Event const*)’; CMakeFiles/sim.dir/src/MyEventAction.cc.o:MyEventAction.cc:(.text+0xae): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/event.cc.o: in function MyEventAction::EndOfEventAction(G4Event const*)': event.cc:(.text+0xb8): multiple definition of
MyEventAction::EndOfEventAction(G4Event const*)‘; CMakeFiles/sim.dir/src/MyEventAction.cc.o:MyEventAction.cc:(.text+0x1aa): first defined here
/usr/bin/ld: CMakeFiles/sim.dir/src/MySensitiveDetector.cc.o:(.data.rel.ro._ZTV19MySensitiveDetector[_ZTV19MySensitiveDetector]+0x28): undefined reference to `MySensitiveDetector::EndOfEvent(G4HCofThisEvent*)’
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/sim.dir/build.make:339: sim] Error 1
make[1]: *** [CMakeFiles/Makefile2:84: CMakeFiles/sim.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
Everytime I am trying to compile these errors pop up and I can’t seem to find the source of this problem, I figured that this was a linking issue and made the necessary changes in the makefile but I am unaware of the changes I should make in the cmake file in order to compile without any errors popping up.
Please help.