Message: Re: how to use ROOT classes within Geant4 Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Re: how to use ROOT classes within Geant4 

Forum: Analysis
Re: Question how to use ROOT classes within Geant4
Date: 20 Nov, 2017
From: <moini78@yahoo.com>

Specifically, I have modified the middle part of the CMakeLists.txt of the example basic/B4c to look like the following:

#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
# Setup include directory for this project
#
include(${Geant4_USE_FILE})

# Setup of ROOT ANALYSIS : optional. option(WITH_ANALYSIS_USE "Build example with analysis objects" OFF) if(WITH_ANALYSIS_USE) add_definitions(-DANALYSIS_USE) else() endif()

include_directories(${PROJECT_SOURCE_DIR}/include)

if(WITH_ANALYSIS_USE)
	EXECUTE_PROCESS(COMMAND root-config --cflags OUTPUT_VARIABLE ROOT_CXX_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ROOT_CXX_FLAGS}")
endif(WITH_ANALYSIS_USE) 

#----------------------------------------------------------------------------
# Locate sources and headers for this project
# NB: headers are included so they will show up in IDEs
#
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc) file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)

#----------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 libraries
#
add_executable(exampleB4c exampleB4c.cc ${sources} ${headers})

if(WITH_ANALYSIS_USE)
	EXECUTE_PROCESS(COMMAND root-config --libs OUTPUT_VARIABLE ROOT_LD_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
	set(CMAKE_EXE_LINKER_FLAGS ${ROOT_LD_FLAGS})
endif(WITH_ANALYSIS_USE)

target_link_libraries(exampleB4c ${Geant4_LIBRARIES}) #----------------------------------------------------------------------------

However, when I make the example, I get the following error message:

CMakeFiles/exampleB4c.dir/exampleB4c.cc.o: In function `_GLOBAL__sub_I_main': exampleB4c.cc:(.text.startup+0x942): undefined reference to `TVersionCheck::TVersionCheck(int)' collect2: error: ld returned 1 exit status CMakeFiles/exampleB4c.dir/build.make:306: recipe for target 'exampleB4c' failed make[2]: *** [exampleB4c] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/exampleB4c.dir/all' failed make[1]: *** [CMakeFiles/exampleB4c.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: *** [all] Error 2

I should add here that I have a local installation of ROOT 6.10/08 in my $Home. Do I need to do something extra than the above modification of CMakeLists.txt for each example file?

Many thanks!

 Add Message Add Message
to: "Re: how to use ROOT classes within Geant4"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]