Include Root header to Geant4 error: Undefined symbols for architecture x86_64: "TVersionCheck::TVersionCheck(int)

The error you see is clang: error: linker command failed with exit code 1 which means you did not link against the libraries of ROOT (you only included the header files). Change this line:

 target_link_libraries(exampleB1 ${Geant4_LIBRARIES} ${ROOT_LIBRARIES})

Also, note that in order to save the output of your analysis in the root file (with histograms, and ntuples) you do not need to attach ROOT to your project. Read more in the user guide or see e.g. examples B3 or B4.

1 Like