Message: Analysis with ROOT and cmake Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Analysis with ROOT and cmake 

Forum: Analysis
Date: 16 Dec, 2011
From: David Krapohl <David Krapohl>

Hello

I am trying to use ROOT directly to write histograms. As suggested here in the forums I tried to compile AnaEx02 which compiles but without linking ROOT.
So my question is, since I am using geant4.9.5 with cmake I would like to know how that works to find ROOT and to set the G4_ANALYSIS variable. Additionally, maybe somebody has an idea about my own code.

In my own code I started with one of the TestEm examples and changed the CMakeLists.txt to:

cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(CdTeDetector)

SET(CMAKE_MODULE_PATH /opt/geant4/geant4.9.5/cmake/Modules/)
find_package(ROOT)
include_directories(/usr/include/root/)

find_package(Geant4 REQUIRED)
include(${Geant4_USE_FILE})

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${Geant4_INCLUDE_DIR})
file(GLOB sources ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc)

add_executable(CdTeDetector EXCLUDE_FROM_ALL CdTeDetector.cc ${sources})
target_link_libraries(CdTeDetector ${Geant4_LIBRARIES})



That works fine meaning that it finds ROOT:

[ analysis »»] >> cmake ..
-- Found ROOT 5.32/00 in /usr
-- Configuring done
-- Generating done
-- Build files have been written to: PhD/Simulations/GEANT4/cdtedetector/build




But compiling it results in a linker error:

[snip]
[100%] Building CXX object CMakeFiles/CdTeDetector.dir/src/DetectorConstruction.cc.o
Linking CXX executable CdTeDetector
CMakeFiles/CdTeDetector.dir/src/Analysis.cc.o: In function `Analysis::PrepareNewRun(G4Run const*)':
Analysis.cc:(.text+0xfb): undefined reference to `TProfile::TProfile(char const*, char const*, int, double, double, char const*)'
Analysis.cc:(.text+0x142): undefined reference to `TH1F::TH1F(char const*, char const*, int, double, double)'
Analysis.cc:(.text+0x15c): undefined reference to `TH1::GetXaxis() const'
Analysis.cc:(.text+0x184): undefined reference to `TObject::operator delete(void*)'
Analysis.cc:(.text+0x198): undefined reference to `TObject::operator delete(void*)'
CMakeFiles/CdTeDetector.dir/src/Analysis.cc.o: In function `Analysis::EndOfRun(G4Run const*)':
Analysis.cc:(.text+0x410): undefined reference to `TFile::Open(char const*, char const*, char const*, int, int)'
CMakeFiles/CdTeDetector.dir/src/Analysis.cc.o: In function `__static_initialization_and_destruction_0(int, int)':
Analysis.cc:(.text+0x58c): undefined reference to `TVersionCheck::TVersionCheck(int)'
CMakeFiles/CdTeDetector.dir/src/Analysis.cc.o: In function `TObject::operator new(unsigned int)':
Analysis.cc:(.text._ZN7TObjectnwEj[TObject::operator new(unsigned int)]+0xd): undefined reference to `TStorage::ObjectAlloc(unsigned int)'
CMakeFiles/CdTeDetector.dir/src/RunAction.cc.o: In function `__static_initialization_and_destruction_0(int, int)':
RunAction.cc:(.text+0x17b0): undefined reference to `TVersionCheck::TVersionCheck(int)'
CMakeFiles/CdTeDetector.dir/src/StackingAction.cc.o: In function `__static_initialization_and_destruction_0(int, int)':
StackingAction.cc:(.text+0xee): undefined reference to `TVersionCheck::TVersionCheck(int)'
CMakeFiles/CdTeDetector.dir/src/SteppingAction.cc.o: In function `__static_initialization_and_destruction_0(int, int)':
SteppingAction.cc:(.text+0x159): undefined reference to `TVersionCheck::TVersionCheck(int)'
CMakeFiles/CdTeDetector.dir/src/EventAction.cc.o: In function `__static_initialization_and_destruction_0(int, int)':
EventAction.cc:(.text+0x3be): undefined reference to `TVersionCheck::TVersionCheck(int)'
collect2: ld returned 1 exit status
make[3]: *** [CdTeDetector] Error 1
make[2]: *** [CMakeFiles/CdTeDetector.dir/all] Error 2
make[1]: *** [CMakeFiles/CdTeDetector.dir/rule] Error 2
make: *** [CdTeDetector] Error 2

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: Analysis with ROOT and cmake   (Matej Batic - 09 Jan, 2012)
1 None: Re: Analysis with ROOT and cmake   (Yngve Inntjore Levinsen - 10 Jan, 2012)
2 None: Re: Analysis with ROOT and cmake   (David Krapohl - 13 Jan, 2012)
3 None: Re: Analysis with ROOT and cmake   (Mathieu Trocmé - 23 Mar, 2012)
1 None: Re: Analysis with ROOT and cmake   (Mathieu Trocmé - 22 Apr, 2012)
4 None: Re: Analysis with ROOT and cmake   (gdss - 29 Oct, 2013)
 Add Message Add Message
to: "Analysis with ROOT and cmake"

 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 ]