Compile error root 6.26/06


I have been trying to write a small code in order to load a tree so I can create a for loop over a a branch. At first I thought It wasn´t going to be difficult until this error came up. I have been looking for different ways to solve it but I don’t know how still:

IncrementalExecutor::executeFunction: symbol ‘_ZN6TClass8GetClassISt6vectorIfSaIfEEEEPS_bb’ unresolved while linking [cling interface function]!
You are probably missing the definition of TClass* TClass::GetClass<std::vector<float, std::allocator > >(bool, bool)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN6TClass8GetClassISt6vectorIiSaIiEEEEPS_bb’ unresolved while linking [cling interface function]!
You are probably missing the definition of TClass* TClass::GetClass<std::vector<int, std::allocator > >(bool, bool)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN6TClass8GetClassIyEEPS_bb’ unresolved while linking [cling interface function]!
You are probably missing the definition of TClass* TClass::GetClass(bool, bool)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN6TClass8GetClassIiEEPS_bb’ unresolved while linking [cling interface function]!
You are probably missing the definition of TClass* TClass::GetClass(bool, bool)
Maybe you need to load the corresponding shared library?

I’m attaching the code too just in case:

  //C and C++ Libraries

#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <fstream>
#include <vector>
#include <algorithm> // for std::find
#include <iterator> // for std::begin, std::end
// ROOT libraries
#include <TROOT.h>
#include <TH1D.h>
#include <TH2D.h>
#include <TTree.h>
#include <TFile.h>
#include <TF1.h>
#include <TRandom3.h>
#include <TCanvas.h>
#include <TChain.h>
#include <TColor.h>
#include <TStyle.h>
#include <TCutG.h>
//#include <TClass.h>
using namespace std;

int main(){

cout<< "Program started at: "<<endl;
system("/bin/date");
cout << endl;


//Defining the histogram 

TH2F *TBA_Dt= new TH2F("TBA_Dt", "Top Bottom Asymmetry; Charge (ADCc); TBA; Events", 500,0,1600000,500,-1,1);

//////////////////////////////////////////
// Declare TTree and Variables          //
//////////////////////////////////////////


//Connect tree file

ifstream finp("inputlist.txt");
string fileinput;

TChain* dstree = new TChain("dstree");
while(finp>>fileinput){
    dstree->Add(fileinput.c_str());
    cout<<"Input file: "<<fileinput<<endl;
}
//Declaration of leaves types
Int_t            ev;
   Int_t           run;
   Int_t           npeaks;
   Int_t           evt_num;
   ULong64_t       trig_cnt;
   vector<int>     *pk_t;
   vector<float>   *pk_p;
   vector<float>   *pk_k;
   vector<int>     *pk_ch;
   vector<int>     *pk_xy;
   vector<int>     *ch_id;
   vector<float>   *ch_bl;
   vector<float>   *ch_rms;
   vector<float>   *ch_roi;
   vector<int>     *ch_sat;
   vector<float>   *ch_osc;
   vector<float>   *ch_fprompt;
   vector<float>   *trig;
   vector<float>   *Dt;
   vector<float>   *Max;
   vector<float>   *MaxP;
   vector<float>   *Min;
   vector<float>   *qP0;
   vector<float>   *qP1;

   
   

    // Set branch addresses and branch pointers

   dstree->SetBranchAddress("ev", &ev);
   dstree->SetBranchAddress("run", &run);
   dstree->SetBranchAddress("npeaks", &npeaks);
   dstree->SetBranchAddress("evt_num", &evt_num);
   dstree->SetBranchAddress("trig_cnt", &trig_cnt);
   dstree->SetBranchAddress("pk_t", &pk_t);
   dstree->SetBranchAddress("pk_p", &pk_p);
   dstree->SetBranchAddress("pk_k", &pk_k);
   dstree->SetBranchAddress("pk_ch", &pk_ch);
   dstree->SetBranchAddress("pk_xy", &pk_xy);
   dstree->SetBranchAddress("ch_id", &ch_id);
   dstree->SetBranchAddress("ch_bl", &ch_bl);
   dstree->SetBranchAddress("ch_rms", &ch_rms);
   dstree->SetBranchAddress("ch_roi", &ch_roi);
   dstree->SetBranchAddress("ch_sat", &ch_sat);
   dstree->SetBranchAddress("ch_osc", &ch_osc);
   dstree->SetBranchAddress("ch_fprompt", &ch_fprompt);
   dstree->SetBranchAddress("trig", &trig);
   dstree->SetBranchAddress("Dt", &Dt);
   dstree->SetBranchAddress("Max", &Max);
   dstree->SetBranchAddress("MaxP", &MaxP);
   dstree->SetBranchAddress("Min", &Min);
   dstree->SetBranchAddress("qP0", &qP0);
   dstree->SetBranchAddress("qP1", &qP1);
   //////////////////////////////////////////////
   // LOOP OVER OUR TTREE                     //
   ////////////////////////////////////////////
   
   // First of all, we are going to set the total number of events we have to study
   
  Long64_t nentries= dstree->GetEntries();
  cout<<"Total events: "<<nentries/1e6<< "millions"<<endl;
  Long64_t totalEvents=0;
  Long64_t nbytes=0;
//dstree->Scan("ch_roi");
  
  
  float tba[nentries]; //¿missed pointer? Code run until this line
  int diff=0;
  for (int i = 0; i < nentries; i++) {
      nbytes=dstree->GetEntry(i);
       tba[i] = (ch_roi[0][i]-0.741*ch_roi[1][i])/(ch_roi[0][i]+0.741*ch_roi[1][i]);
    
    diff=tba[i]-tba[i-1];
    if(diff<0.01){
      TBA_Dt->Fill(tba[i],ch_roi[0][i]+0.741*ch_roi[1][i]);  
    }
    
}

 ///////////////////////////////////////////////
//               Opening output file         //
/////////////////////////////////////////////

    cout<<"Opening output file"<<endl;
    
    TFile *output_file=new TFile("results_run00508.root","recreate");//change the name if the run of the inputlist changes
    
    TDirectory *TopBottomAsymmetry=output_file->mkdir("Top Bottom Asymmetry");
    
    cout<<"Output file opened"<< endl;
    
    
//////////////////////////////////////////////
//           Writing output file           //
////////////////////////////////////////////
    
    
    //TopBottomAsymmetry
    TopBottomAsymmetry->cd();
    TBA_Dt->Write();
    return 0;
 }   
    void analyze2(){
        main();
    }

_ROOT Version: 6.26/06
Platform: Ubuntu
Compiler: Not Provided


Hi @RAFALPZN,

I cannot reproduce the linking problems that you are experiencing above (cited), at least with ROOT built from up-to-date sources from the master branch. This possibly relates to something on your environment. Where did you installed ROOT from (e.g., built from source, Conda package, etc.)?

Remember that you can also compile a stand-alone executable for your macro (as opposed to using the interpreter), as follows:

$ g++ `root-config --cflags --libs` -o analyze2 analyze2.C

Cheers,
J.

Hi @jalopezg

Thank you so much for yout answer. I installed the Linux Kernel in Windows (Ubuntu 20.04), and then I installed root. I believe I did it following the steps pre-compiled binary distribution section. I have tried the command that you told me but it didn’t wotk either. I don’t know, could it be a install problem?

Thanks again

Rafa

So it’s on WSL via a pre-compiled binary. @bellenot have you seen something similar before?

Could you please give more details on the issue? The command in my previous post assumes you have a working GCC toolchain (you might need to install build-essentials). Do you get compilation errors instead?

Cheers,
J.

Thanks again for your help! I do have a GCC and build-essentials installed. When I run the command that you told me I get the following error:

/usr/bin/ld: /tmp/ccKte1Kw.o: in function Vc_1::Common::(anonymous namespace)::runLibraryAbiCheck::runLibraryAbiCheck()': analyze2.C:(.text+0x1e): undefined reference to Vc_1::Common::checkLibraryAbi(unsigned int, unsigned int, char const*)’
/usr/bin/ld: /tmp/ccKte1Kw.o: in function Vc_1::_doRandomStep(Vc_1::Vector<unsigned int, Vc_1::VectorAbi::Sse>&, Vc_1::Vector<unsigned int, Vc_1::VectorAbi::Sse>&)': analyze2.C:(.text+0x6b): undefined reference to Vc_1::Common::RandomState’
/usr/bin/ld: analyze2.C:(.text+0x196): undefined reference to Vc_1::Common::RandomState' /usr/bin/ld: analyze2.C:(.text+0x72f): undefined reference to Vc_1::Common::RandomState’
/usr/bin/ld: analyze2.C:(.text+0xd4b): undefined reference to Vc_1::Common::RandomState' /usr/bin/ld: /tmp/ccKte1Kw.o: in function main’:
analyze2.C:(.text+0xfad): undefined reference to TH2F::TH2F(char const*, char const*, int, double, double, int, double, double)' /usr/bin/ld: analyze2.C:(.text+0x1006): undefined reference to TChain::TChain(char const*, char const*, TChain::Mode)’
/usr/bin/ld: analyze2.C:(.text+0x1810): undefined reference to TFile::TFile(char const*, char const*, char const*, int)' /usr/bin/ld: analyze2.C:(.text+0x1916): undefined reference to TObject::operator delete(void*)’
/usr/bin/ld: analyze2.C:(.text+0x1930): undefined reference to TObject::operator delete(void*)' /usr/bin/ld: analyze2.C:(.text+0x1944): undefined reference to TObject::operator delete(void*)’
/usr/bin/ld: /tmp/ccKte1Kw.o: in function __static_initialization_and_destruction_0(int, int)': analyze2.C:(.text+0x1ad8): undefined reference to TVersionCheck::TVersionCheck(int)’
/usr/bin/ld: /tmp/ccKte1Kw.o: in function TObject::operator new(unsigned long)': analyze2.C:(.text._ZN7TObjectnwEm[_ZN7TObjectnwEm]+0x18): undefined reference to TStorage::ObjectAlloc(unsigned long)’
/usr/bin/ld: /tmp/ccKte1Kw.o: in function int TTree::SetBranchAddress<int>(char const*, int*, TBranch**)': analyze2.C:(.text._ZN5TTree16SetBranchAddressIiEEiPKcPT_PP7TBranch[_ZN5TTree16SetBranchAddressIiEEiPKcPT_PP7TBranch]+0x45): undefined reference to TDataType::GetType(std::type_info const&)’
/usr/bin/ld: /tmp/ccKte1Kw.o: in function int TTree::SetBranchAddress<unsigned long long>(char const*, unsigned long long*, TBranch**)': analyze2.C:(.text._ZN5TTree16SetBranchAddressIyEEiPKcPT_PP7TBranch[_ZN5TTree16SetBranchAddressIyEEiPKcPT_PP7TBranch]+0x45): undefined reference to TDataType::GetType(std::type_info const&)’
/usr/bin/ld: /tmp/ccKte1Kw.o: in function int TTree::SetBranchAddress<std::vector<int, std::allocator<int> > >(char const*, std::vector<int, std::allocator<int> >**, TBranch**)': analyze2.C:(.text._ZN5TTree16SetBranchAddressISt6vectorIiSaIiEEEEiPKcPPT_PP7TBranch[_ZN5TTree16SetBranchAddressISt6vectorIiSaIiEEEEiPKcPPT_PP7TBranch]+0x45): undefined reference to TDataType::GetType(std::type_info const&)’
/usr/bin/ld: /tmp/ccKte1Kw.o: in function int TTree::SetBranchAddress<std::vector<float, std::allocator<float> > >(char const*, std::vector<float, std::allocator<float> >**, TBranch**)': analyze2.C:(.text._ZN5TTree16SetBranchAddressISt6vectorIfSaIfEEEEiPKcPPT_PP7TBranch[_ZN5TTree16SetBranchAddressISt6vectorIfSaIfEEEEiPKcPPT_PP7TBranch]+0x45): undefined reference to TDataType::GetType(std::type_info const&)’
/usr/bin/ld: /tmp/ccKte1Kw.o: in function ROOT::Internal::TClassGetClassHelper<int>::GetClass(bool, bool)': analyze2.C:(.text._ZN4ROOT8Internal20TClassGetClassHelperIiE8GetClassEbb[_ZN4ROOT8Internal20TClassGetClassHelperIiE8GetClassEbb]+0x33): undefined reference to TClass::GetClass(std::type_info const&, bool, bool, unsigned long, unsigned long)’
/usr/bin/ld: /tmp/ccKte1Kw.o: in function ROOT::Internal::TClassGetClassHelper<unsigned long long>::GetClass(bool, bool)': analyze2.C:(.text._ZN4ROOT8Internal20TClassGetClassHelperIyE8GetClassEbb[_ZN4ROOT8Internal20TClassGetClassHelperIyE8GetClassEbb]+0x33): undefined reference to TClass::GetClass(std::type_info const&, bool, bool, unsigned long, unsigned long)’
/usr/bin/ld: /tmp/ccKte1Kw.o: in function ROOT::Internal::TClassGetClassHelper<std::vector<int, std::allocator<int> > >::GetClass(bool, bool)': analyze2.C:(.text._ZN4ROOT8Internal20TClassGetClassHelperISt6vectorIiSaIiEEE8GetClassEbb[_ZN4ROOT8Internal20TClassGetClassHelperISt6vectorIiSaIiEEE8GetClassEbb]+0x33): undefined reference to TClass::GetClass(std::type_info const&, bool, bool, unsigned long, unsigned long)’
/usr/bin/ld: /tmp/ccKte1Kw.o: in function ROOT::Internal::TClassGetClassHelper<std::vector<float, std::allocator<float> > >::GetClass(bool, bool)': analyze2.C:(.text._ZN4ROOT8Internal20TClassGetClassHelperISt6vectorIfSaIfEEE8GetClassEbb[_ZN4ROOT8Internal20TClassGetClassHelperISt6vectorIfSaIfEEE8GetClassEbb]+0x33): undefined reference to TClass::GetClass(std::type_info const&, bool, bool, unsigned long, unsigned long)’
collect2: error: ld returned 1 exit status

Could it be a error in the code attached at the beginning of the conversation?

R.

$(root-config --cxx --cflags) -O2 -Wall -Wextra -o analyze2 analyze2.C $(root-config --libs)

BTW. All pointers MUST be initialized: vector<...> *... = 0;

Hello!

I have tried your command and initialized all the pointers. Using " root analyze2.C ", the file is loaded and the number of events it’s shown. However, once reached the loops the code stops and the error that I posted in the first message appears.

IncrementalExecutor::executeFunction: symbol ‘_ZN6TClass8GetClassISt6vectorIiSaIiEEEEPS_bb’ unresolved while linking [cling interface function]!
You are probably missing the definition of TClass* TClass::GetClass<std::vector<int, std::allocator > >(bool, bool)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN6TClass8GetClassISt6vectorIfSaIfEEEEPS_bb’ unresolved while linking [cling interface function]!
You are probably missing the definition of TClass* TClass::GetClass<std::vector<float, std::allocator > >(bool, bool)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN6TClass8GetClassIyEEPS_bb’ unresolved while linking [cling interface function]!
You are probably missing the definition of TClass* TClass::GetClass(bool, bool)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol ‘_ZN6TClass8GetClassIiEEPS_bb’ unresolved while linking [cling interface function]!
You are probably missing the definition of TClass* TClass::GetClass(bool, bool)
Maybe you need to load the corresponding shared library?

I have tried your command as well, no error message appears. Nevertheless, the output file is not being created. If I /* all the LOOP over our tree section the code works, could it be an error in that part?

Thank you so much for your help!!!

R.

The “ch_roi[0][i]” and “ch_roi[1][i]” do not make sense.
You should use “ch_roi->at(0)” and “ch_roi->at(1)” instead.

Try a simple “analysis skeleton”: dstree->MakeClass();

Ok thanks!!!

I was trying to make my loop run through the two channels that ch_roi has.

Also, the command that we mentioned generates a binary executable file, i.e. instead of doing

$ root analyze2.C

you can just run the compiled binary as in

$ ./analyze2

Cheers,
J.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.