Problem related to running Geant4 with ROOT

Hello, I have written a code in Geant4.8.0.p01, and part of the code is to output the track information into a ROOT Tree. However, when I tried to make the file, it said to me the following error:
Is it related to setting environment variable?
Compiling MySteppingAction.cc
In file included from /usr/local/root_v4.04_02g/include/Rtypes.h:30,
from include/PDBD.h:4,
from src/MySteppingAction.cc:6:
/usr/local/root_v4.04_02g/include/Rtypeinfo.h:33: error: expected unqualified-id before "using"
In file included from include/PDBD.h:4,
from src/MySteppingAction.cc:6:
/usr/local/root_v4.04_02g/include/Rtypes.h:168: error: expected ,' or…’ before ‘&’ token
/usr/local/root_v4.04_02g/include/Rtypes.h:171: error: ISO C++ forbids declaration of type_info' with no type /usr/local/root_v4.04_02g/include/Rtypes.h:172: error: expected,’ or ...' before '&' token /usr/local/root_v4.04_02g/include/Rtypes.h:173: error: ISO C++ forbids declaration oftype_info’ with no type
/usr/local/root_v4.04_02g/include/Rtypes.h:198: error: expected ,' or…’ before ‘&’ token
/usr/local/root_v4.04_02g/include/Rtypes.h:199: error: ISO C++ forbids declaration of type_info' with no type /usr/local/root_v4.04_02g/include/Rtypes.h:202: error: expected,’ or ...' before '&' token /usr/local/root_v4.04_02g/include/Rtypes.h:205: error: ISO C++ forbids declaration oftype_info’ with no type
/usr/local/root_v4.04_02g/include/Rtypes.h:210: error: expected ,' or…’ before ‘&’ token
/usr/local/root_v4.04_02g/include/Rtypes.h:211: error: ISO C++ forbids declaration of type_info' with no type /usr/local/root_v4.04_02g/include/Rtypes.h:218: error: expected,’ or ...' before '&' token /usr/local/root_v4.04_02g/include/Rtypes.h:221: error: ISO C++ forbids declaration oftype_info’ with no type
/usr/local/root_v4.04_02g/include/Rtypes.h: In member function virtual void ROOT::TDefaultInitBehavior::Register(const char*, Version_t, int) const': /usr/local/root_v4.04_02g/include/Rtypes.h:212: error:info’ was not declared in this scope
/usr/local/root_v4.04_02g/include/Rtypes.h:212: error: dict' was not declared in this scope /usr/local/root_v4.04_02g/include/Rtypes.h:212: error:pragmabits’ was not declared in this scope
/usr/local/root_v4.04_02g/include/Rtypes.h:212: warning: unused variable ‘info’
/usr/local/root_v4.04_02g/include/Rtypes.h:212: warning: unused variable ‘dict’
/usr/local/root_v4.04_02g/include/Rtypes.h:212: warning: unused variable ‘pragmabits’
/usr/local/root_v4.04_02g/include/Rtypes.h: In member function virtual TClass* ROOT::TDefaultInitBehavior::CreateClass(const char*, Version_t, int) const': /usr/local/root_v4.04_02g/include/Rtypes.h:222: error:info’ was not declared in this scope
/usr/local/root_v4.04_02g/include/Rtypes.h:222: error: isa' was not declared in this scope /usr/local/root_v4.04_02g/include/Rtypes.h:222: error:show’ was not declared in this scope
/usr/local/root_v4.04_02g/include/Rtypes.h:222: error: dfil' was not declared in this scope /usr/local/root_v4.04_02g/include/Rtypes.h:222: error:ifil’ was not declared in this scope
/usr/local/root_v4.04_02g/include/Rtypes.h:222: error: dl' was not declared in this scope /usr/local/root_v4.04_02g/include/Rtypes.h:222: error:il’ was not declared in this scope
/usr/local/root_v4.04_02g/include/Rtypes.h:222: warning: unused variable ‘info’
/usr/local/root_v4.04_02g/include/Rtypes.h:222: warning: unused variable ‘isa’
/usr/local/root_v4.04_02g/include/Rtypes.h:222: warning: unused variable ‘show’
/usr/local/root_v4.04_02g/include/Rtypes.h:222: warning: unused variable ‘dfil’
/usr/local/root_v4.04_02g/include/Rtypes.h:222: warning: unused variable ‘ifil’
/usr/local/root_v4.04_02g/include/Rtypes.h:222: warning: unused variable ‘dl’
/usr/local/root_v4.04_02g/include/Rtypes.h:222: warning: unused variable ‘il’
In file included from /usr/local/root_v4.04_02g/include/Rtypes.h:233,
from include/PDBD.h:4,
from src/MySteppingAction.cc:6:
/usr/local/root_v4.04_02g/include/TGenericClassInfo.h: At global scope:
/usr/local/root_v4.04_02g/include/TGenericClassInfo.h:28: error: ISO C++ forbids declaration of type_info' with no type /usr/local/root_v4.04_02g/include/TGenericClassInfo.h:28: error: expected;’ before ‘&’ token
/usr/local/root_v4.04_02g/include/TGenericClassInfo.h:46: error: expected ,' or…’ before ‘&’ token
/usr/local/root_v4.04_02g/include/TGenericClassInfo.h:48: error: ISO C++ forbids declaration of type_info' with no type /usr/local/root_v4.04_02g/include/TGenericClassInfo.h:52: error: expected,’ or ...' before '&' token /usr/local/root_v4.04_02g/include/TGenericClassInfo.h:54: error: ISO C++ forbids declaration oftype_info’ with no type
/usr/local/root_v4.04_02g/include/TGenericClassInfo.h:58: error: expected ,' or…’ before ‘&’ token
/usr/local/root_v4.04_02g/include/TGenericClassInfo.h:60: error: ISO C++ forbids declaration of type_info' with no type /usr/local/root_v4.04_02g/include/TGenericClassInfo.h:60: error:ROOT::TGenericClassInfo::TGenericClassInfo(const char*, Int_t, const char*, Int_t, int)’ and ROOT::TGenericClassInfo::TGenericClassInfo(const char*, Int_t, const char*, Int_t, int)' cannot be overloaded /usr/local/root_v4.04_02g/include/TGenericClassInfo.h:80: error: ISO C++ forbids declaration oftype_info’ with no type
/usr/local/root_v4.04_02g/include/TGenericClassInfo.h:80: error: expected ;' before '&' token In file included from /usr/local/root_v4.04_02g/include/TObject.h:194, from include/PDBD.h:5, from src/MySteppingAction.cc:6: /usr/local/root_v4.04_02g/include/TBuffer.h:246: error: expected,’ or ...' before '&' token /usr/local/root_v4.04_02g/include/TBuffer.h:246: error: ISO C++ forbids declaration oftype_info’ with no type
/usr/local/root_v4.04_02g/include/TBuffer.h:288: error: expected ,' or…’ before ‘&’ token
/usr/local/root_v4.04_02g/include/TBuffer.h:288: error: ISO C++ forbids declaration of type_info' with no type /usr/local/root_v4.04_02g/include/TBuffer.h: In functionTBuffer& operator>>(TBuffer&, Tmpl*&)’:
/usr/local/root_v4.04_02g/include/TBuffer.h:314: error: no matching function for call to TBuffer::GetClass(const std::type_info&)' /usr/local/root_v4.04_02g/include/TBuffer.h:288: note: candidates are: static TClass* TBuffer::GetClass(int) /usr/local/root_v4.04_02g/include/TBuffer.h:289: note: static TClass* TBuffer::GetClass(const char*) /usr/local/root_v4.04_02g/include/TBuffer.h: In functionTBuffer& operator<<(TBuffer&, const Tmpl*)’:
/usr/local/root_v4.04_02g/include/TBuffer.h:321: error: no matching function for call to TBuffer::GetClass(const std::type_info&)' /usr/local/root_v4.04_02g/include/TBuffer.h:288: note: candidates are: static TClass* TBuffer::GetClass(int) /usr/local/root_v4.04_02g/include/TBuffer.h:289: note: static TClass* TBuffer::GetClass(const char*) In file included from /usr/local/root_v4.04_02g/include/TROOT.h:29, from /usr/local/root_v4.04_02g/include/TClass.h:31, from /usr/local/root_v4.04_02g/include/TVirtualTreePlayer.h:25, from /usr/local/root_v4.04_02g/include/TTree.h:67, from include/PDBD.h:6, from src/MySteppingAction.cc:6: /usr/local/root_v4.04_02g/include/TDirectory.h: In member functionvoid TDirectory::GetObject(const char*, T*&)’:
/usr/local/root_v4.04_02g/include/TDirectory.h:95: error: no matching function for call to TBuffer::GetClass(const std::type_info&)' /usr/local/root_v4.04_02g/include/TBuffer.h:288: note: candidates are: static TClass* TBuffer::GetClass(int) /usr/local/root_v4.04_02g/include/TBuffer.h:289: note: static TClass* TBuffer::GetClass(const char*) /usr/local/root_v4.04_02g/include/TDirectory.h: In member functionInt_t TDirectory::WriteObject(const T*, const char*, const Option_t*)’:
/usr/local/root_v4.04_02g/include/TDirectory.h:139: error: no matching function for call to TBuffer::GetClass(const std::type_info&)' /usr/local/root_v4.04_02g/include/TBuffer.h:288: note: candidates are: static TClass* TBuffer::GetClass(int) /usr/local/root_v4.04_02g/include/TBuffer.h:289: note: static TClass* TBuffer::GetClass(const char*) In file included from /usr/local/root_v4.04_02g/include/TClass.h:31, from /usr/local/root_v4.04_02g/include/TVirtualTreePlayer.h:25, from /usr/local/root_v4.04_02g/include/TTree.h:67, from include/PDBD.h:6, from src/MySteppingAction.cc:6: /usr/local/root_v4.04_02g/include/TROOT.h: At global scope: /usr/local/root_v4.04_02g/include/TROOT.h:148: error: expected,’ or ...' before '&' token /usr/local/root_v4.04_02g/include/TROOT.h:148: error: ISO C++ forbids declaration oftype_info’ with no type
In file included from /usr/local/root_v4.04_02g/include/TVirtualTreePlayer.h:25, from /usr/local/root_v4.04_02g/include/TTree.h:67,
from include/PDBD.h:6,
from src/MySteppingAction.cc:6:
/usr/local/root_v4.04_02g/include/TClass.h:90: error: ISO C++ forbids declaration of type_info' with no type /usr/local/root_v4.04_02g/include/TClass.h:90: error: expected;’ before ‘’ token
/usr/local/root_v4.04_02g/include/TClass.h:121: error: expected ,' or…’ before '
’ token
/usr/local/root_v4.04_02g/include/TClass.h:124: error: ISO C++ forbids declaration of type_info' with no type /usr/local/root_v4.04_02g/include/TClass.h:144: error: expected,’ or ...' before '&' token /usr/local/root_v4.04_02g/include/TClass.h:147: error: ISO C++ forbids declaration oftype_info’ with no type
/usr/local/root_v4.04_02g/include/TClass.h:207: error: ISO C++ forbids declaration of type_info' with no type /usr/local/root_v4.04_02g/include/TClass.h:207: error: expected;’ before ‘’ token
/usr/local/root_v4.04_02g/include/TClass.h:244: error: expected ,' or…’ before ‘&’ token
/usr/local/root_v4.04_02g/include/TClass.h:244: error: ISO C++ forbids declaration of type_info' with no type /usr/local/root_v4.04_02g/include/TClass.h:246: error: expected,’ or ...' before '&' token /usr/local/root_v4.04_02g/include/TClass.h:246: error: ISO C++ forbids declaration oftype_info’ with no type
In file included from /usr/local/root_v4.04_02g/include/TTree.h:71,
from include/PDBD.h:6,
from src/MySteppingAction.cc:6:
/usr/local/root_v4.04_02g/include/TDataType.h:69: error: expected ,' or…’ before ‘&’ token
/usr/local/root_v4.04_02g/include/TDataType.h:69: error: ISO C++ forbids declaration of type_info' with no type In file included from include/PDBD.h:6, from src/MySteppingAction.cc:6: /usr/local/root_v4.04_02g/include/TTree.h: In member functionTBranch
TTree::Branch(const char*, const char*, T**, Int_t, Int_t)’:
/usr/local/root_v4.04_02g/include/TTree.h:198: error: no matching function for call to TBuffer::GetClass(const std::type_info&)' /usr/local/root_v4.04_02g/include/TBuffer.h:288: note: candidates are: static TClass* TBuffer::GetClass(int) /usr/local/root_v4.04_02g/include/TBuffer.h:289: note: static TClass* TBuffer::GetClass(const char*) /usr/local/root_v4.04_02g/include/TTree.h: In member functionTBranch* TTree::Branch(const char*, T**, Int_t, Int_t)’:
/usr/local/root_v4.04_02g/include/TTree.h:203: error: no matching function for call to TBuffer::GetClass(const std::type_info&)' /usr/local/root_v4.04_02g/include/TBuffer.h:288: note: candidates are: static TClass* TBuffer::GetClass(int) /usr/local/root_v4.04_02g/include/TBuffer.h:289: note: static TClass* TBuffer::GetClass(const char*) /usr/local/root_v4.04_02g/include/TTree.h: In member functionvoid TTree::SetBranchAddress(const char*, T**)’:
/usr/local/root_v4.04_02g/include/TTree.h:341: error: no matching function for call to TDataType::GetType(const std::type_info&)' /usr/local/root_v4.04_02g/include/TDataType.h:62: note: candidates are: Int_t TDataType::GetType() const /usr/local/root_v4.04_02g/include/TDataType.h:69: note: static EDataType TDataType::GetType(int) /usr/local/root_v4.04_02g/include/TTree.h: In member functionvoid TTree::SetBranchAddress(const char*, T*)’:
/usr/local/root_v4.04_02g/include/TTree.h:347: error: no matching function for call to TDataType::GetType(const std::type_info&)' /usr/local/root_v4.04_02g/include/TDataType.h:62: note: candidates are: Int_t TDataType::GetType() const /usr/local/root_v4.04_02g/include/TDataType.h:69: note: static EDataType TDataType::GetType(int) src/MySteppingAction.cc: In member functionvirtual void MySteppingAction::UserSteppingAction(const G4Step*)’:
src/MySteppingAction.cc:23: error: gTrack' was not declared in this scope src/MySteppingAction.cc:30: error:fTrack’ was not declared in this scope
src/MySteppingAction.cc:33: warning: deprecated conversion from string constant to char*' src/MySteppingAction.cc:36: error:fStep’ was not declared in this scope
src/MySteppingAction.cc:40: warning: deprecated conversion from string constant to char*' src/MySteppingAction.cc:42: error:out’ was not declared in this scope
src/MySteppingAction.cc:22: warning: unused variable 'gtrack’
make: *** [/home/klhui/tmp/Linux-g++/sure/MySteppingAction.o] Error 1

Thanks for your help

Hi,

Most likely you set up you include path (-I option on the compiler command line) such that #include <typeinfo>does not pick the compiler’s own version of typeinfo … or you are building on a platform that those not properly put typeinfo into the std namespace …

Philippe