CMake File issue

Hi, I am running a GEANT4 program that calls upon ROOT files and headers. In the cmake file I have included ROOT directories :

# Locate sources and headers for this project
#
include_directories(${PROJECT_SOURCE_DIR}/include
                    ${Geant4_INCLUDE_DIR}
	            ${ROOT_INCLUDE_DIRS})  		
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)

However, when I run the CMake file I run into these errors :

/usr/bin/ld: CMakeFiles/FCP_Simulation.dir/src/ActionInitialization.cc.o: in function `_GLOBAL__sub_I_ActionInitialization.cc':
ActionInitialization.cc:(.text.startup+0x44): undefined reference to `TVersionCheck::TVersionCheck(int)'
/usr/bin/ld: CMakeFiles/FCP_Simulation.dir/src/EventAction.cc.o: in function `EventAction::EventAction(RunAction*)':
EventAction.cc:(.text+0x229): undefined reference to `TStorage::ObjectAlloc(unsigned long)'
/usr/bin/ld: EventAction.cc:(.text+0x24f): undefined reference to `TFile::TFile(char const*, char const*, char const*, int)'
/usr/bin/ld: EventAction.cc:(.text+0x258): undefined reference to `TDirectory::CurrentDirectory()'
/usr/bin/ld: EventAction.cc:(.text+0x265): undefined reference to `TStorage::ObjectAlloc(unsigned long)'
/usr/bin/ld: EventAction.cc:(.text+0x286): undefined reference to `TTree::TTree(char const*, char const*, int, TDirectory*)'
/usr/bin/ld: EventAction.cc:(.text+0x2aa): undefined reference to `TTree::Branch(char const*, void*, char const*, int)'
/usr/bin/ld: CMakeFiles/FCP_Simulation.dir/src/EventAction.cc.o: in function `_GLOBAL__sub_I_EventAction.cc':
EventAction.cc:(.text.startup+0x38): undefined reference to `TVersionCheck::TVersionCheck(int)'
/usr/bin/ld: CMakeFiles/FCP_Simulation.dir/src/EventAction.cc.o: in function `EventAction::EventAction(RunAction*) [clone .cold]':
EventAction.cc:(.text.unlikely+0x4): undefined reference to `TObject::operator delete(void*)'
/usr/bin/ld: EventAction.cc:(.text.unlikely+0x1c): undefined reference to `TObject::operator delete(void*)'
/usr/bin/ld: CMakeFiles/FCP_Simulation.dir/src/SteppingAction.cc.o: in function `_GLOBAL__sub_I_SteppingAction.cc':
SteppingAction.cc:(.text.startup+0x38): undefined reference to `TVersionCheck::TVersionCheck(int)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/FCP_Simulation.dir/build.make:400: FCP_Simulation] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/FCP_Simulation.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

I included the ROOT Libraries so I don’t know why I am getting the errors.

The error says the linker is missing ROOT libraries (so it’s not about ROOT includes).

Hi, thank you, how would I go about in including ROOT Libraries?

Geant4 → User Forum

E.g.:

1 Like