Undefined reference to Error

Hi,

I need to understand what is “undefined reference to” means?? what is missing??

please check the below error when i try to run the code. Just need to know is the error from ROOT or my code?

thanks,

Mai

melsawy@lxplus0051 bin]$ g++ monoNtupleAnalyzer.cc -o monoNtupleAnalyzer root-config --cflags

/tmp/melsawy/ccL5doBj.o: In function main': monoNtupleAnalyzer.cc:(.text+0x2ec): undefined reference toTFile::TFile(char const*, char const*, char const*, int)'
monoNtupleAnalyzer.cc:(.text+0x300): undefined reference to TDirectoryFile::Get(char const*)' monoNtupleAnalyzer.cc:(.text+0x5ad): undefined reference toTFile::TFile(char const*, char const*, char const*, int)‘
monoNtupleAnalyzer.cc:(.text+0x5bd): undefined reference to TObject::operator delete(void*)' monoNtupleAnalyzer.cc:(.text+0xf4b): undefined reference toTFile::~TFile()‘
monoNtupleAnalyzer.cc:(.text+0xf62): undefined reference to TFile::~TFile()' /tmp/melsawy/ccL5doBj.o: In function__static_initialization_and_destruction_0(int, int)’:
monoNtupleAnalyzer.cc:(.text+0x1050): undefined reference to TVersionCheck::TVersionCheck(int)' /tmp/melsawy/ccL5doBj.o: In functionTObject::operator new(unsigned long)’:

/tmp/melsawy/ccL5doBj.o: In function int TTree::SetBranchAddress<std::vector<bool, std::allocator<bool> > >(char const*, std::vector<bool, std::allocator<bool> >**, TBranch**)': monoNtupleAnalyzer.cc:(.text._ZN5TTree16SetBranchAddressISt6vectorIbSaIbEEEEiPKcPPT_PP7TBranch[int TTree::SetBranchAddress<std::vector<bool, std::allocator<bool> > >(char const*, std::vector<bool, std::allocator<bool> >**, TBranch**)]+0x2c): undefined reference toTClass::GetClass(std::type_info const&, bool, bool)‘
monoNtupleAnalyzer.cc:(.text._ZN5TTree16SetBranchAddressISt6vectorIbSaIbEEEEiPKcPPT_PP7TBranch[int TTree::SetBranchAddress<std::vector<bool, std::allocator > >(char const*, std::vector<bool, std::allocator >, TBranch)]+0x4b): undefined reference to TDataType::GetType(std::type_info const&)' /tmp/melsawy/ccL5doBj.o: In functionint TTree::SetBranchAddress<std::vector<std::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::basic_string<char, std::char_traits, std::allocator > > > >(char const*, std::vector<std::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::basic_string<char, std::char_traits, std::allocator > > >, TBranch)’:
monoNtupleAnalyzer.cc:(.text._ZN5TTree16SetBranchAddressISt6vectorISsSaISsEEEEiPKcPPT_PP7TBranch[int TTree::SetBranchAddress<std::vector<std::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::basic_string<char, std::char_traits, std::allocator > > > >(char const*, std::vector<std::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::basic_string<char, std::char_traits, std::allocator > > >, TBranch)]+0x2c): undefined reference to TClass::GetClass(std::type_info const&, bool, bool)' monoNtupleAnalyzer.cc:(.text._ZN5TTree16SetBranchAddressISt6vectorISsSaISsEEEEiPKcPPT_PP7TBranch[int TTree::SetBranchAddress<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >(char const*, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >**, TBranch**)]+0x4b): undefined reference toTDataType::GetType(std::type_info const&)’
/tmp/melsawy/ccL5doBj.o: In function int TTree::SetBranchAddress<unsigned int>(char const*, unsigned int*, TBranch**)': monoNtupleAnalyzer.cc:(.text._ZN5TTree16SetBranchAddressIjEEiPKcPT_PP7TBranch[int TTree::SetBranchAddress<unsigned int>(char const*, unsigned int*, TBranch**)]+0x2c): undefined reference toTClass::GetClass(std::type_info const&, bool, bool)‘
monoNtupleAnalyzer.cc:(.text._ZN5TTree16SetBranchAddressIjEEiPKcPT_PP7TBranch[int TTree::SetBranchAddress(char const*, unsigned int*, TBranch**)]+0x4b): undefined reference to TDataType::GetType(std::type_info const&)' /tmp/melsawy/ccL5doBj.o: In functionint TTree::SetBranchAddress<std::vector<double, std::allocator > >(char const*, std::vector<double, std::allocator >, TBranch)’:
monoNtupleAnalyzer.cc:(.text._ZN5TTree16SetBranchAddressISt6vectorIdSaIdEEEEiPKcPPT_PP7TBranch[int TTree::SetBranchAddress<std::vector<double, std::allocator > >(char const*, std::vector<double, std::allocator >, TBranch)]+0x2c): undefined reference to TClass::GetClass(std::type_info const&, bool, bool)' monoNtupleAnalyzer.cc:(.text._ZN5TTree16SetBranchAddressISt6vectorIdSaIdEEEEiPKcPPT_PP7TBranch[int TTree::SetBranchAddress<std::vector<double, std::allocator<double> > >(char const*, std::vector<double, std::allocator<double> >**, TBranch**)]+0x4b): undefined reference toTDataType::GetType(std::type_info const&)’
/tmp/melsawy/ccL5doBj.o:(.rodata._ZTV10TCanvasImp[vtable for TCanvasImp]+0xf8): undefined reference to TCanvasImp::ShowMembers(TMemberInspector&)' /tmp/melsawy/ccL5doBj.o:(.rodata._ZTV10TCanvasImp[vtable for TCanvasImp]+0x100): undefined reference toTCanvasImp::Streamer(TBuffer&)’
/tmp/melsawy/ccL5doBj.o:(.rodata._ZTV15TApplicationImp[vtable for TApplicationImp]+0x78): undefined reference to TApplicationImp::ShowMembers(TMemberInspector&)' /tmp/melsawy/ccL5doBj.o:(.rodata._ZTV15TApplicationImp[vtable for TApplicationImp]+0x80): undefined reference toTApplicationImp::Streamer(TBuffer&)'
collect2: ld returned 1 exit status

Hi,

the error is not a root error but a simple linker error. Try:

g++ monoNtupleAnalyzer.cc -o monoNtupleAnalyzer `root-config --cflags --libs`

Cheers,
Danilo

Hi,

i tried and it didn’t give the previous error but when i type the next command i got the below
-bash: monoNtupleAnalyzer: command not found

Do you know what i am missing ?

thanks,

Mai

[melsawy@lxplus139 bin]$ g++ monoNtupleAnalyzer.cc -o monoNtupleAnalyzer root-config --cflags --libs
[melsawy@lxplus139 bin]$ monoNtupleAnalyzer -i Ntuple_RECO3.root -o histo.root
-bash: monoNtupleAnalyzer: command not found

./monoNtupleAnalyzer …

I am sorry but i am trying to understand , is the below crash due to root version or something else in my code?

thanks,

Mai

[melsawy@lxplus073 bin]$ ./monoNtupleAnalyzer -i Ntuple_RECO3.root -o histo.root

*** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:

#0 0x00007f8e713907be in waitpid () from /lib64/libc.so.6
#1 0x00007f8e713225c9 in do_system () from /lib64/libc.so.6
#2 0x00007f8e75f2bb04 in TUnixSystem::StackTrace() () from /usr/lib64/root/libCore.so.5.34
#3 0x00007f8e75f2af23 in TUnixSystem::DispatchSignals(ESignals) () from /usr/lib64/root/libCore.so.5.34
#4
#5 0x00000000004150ee in int TTree::SetBranchAddress<std::vector<bool, std::allocator > >(char const*, std::vector<bool, std::allocator >, TBranch) ()
#6 0x000000000040f739 in main ()

The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.

#5 0x00000000004150ee in int TTree::SetBranchAddress<std::vector<bool, std::allocator > >(char const*, std::vector<bool, std::allocator >, TBranch) ()
#6 0x000000000040f739 in main ()

Segmentation fault
[melsawy@lxplus073 bin]$

Hi,

most likely yes.

Danilo