I am trying to use classes generated by TFile::MakeProject in my macro. When I try to use ClassA in my macro (classA is defined in the generated library), I get undefined symbol error:
[lzer@68snzq1-wired ClassA_dbg]$ root -l libtest.C++
root [0]
Processing libtest.C++...
Info in <TUnixSystem::ACLiC>: creating shared library /home/bloo/ClassA_dbg/./libtest_C.so
cling::DynamicLibraryManager::loadLibrary(): /home/bloo/ClassA_dbg/libtest_C.so: undefined symbol: _ZTI20ClassA
/lib/../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
/home/bloo/ClassA_dbg/libtest_C_ACLiC_dict.o: In function `int TTree::SetBranchAddress<ClassA>(char const*, ClassA*, TBranch**)':
libtest_C_ACLiC_dict.cxx:(.text._ZN5TTree16SetBranchAddressI20ClassAEEiPKcPT_PP7TBranch[_ZN5TTree16SetBranchAddressI20ClassAEEiPKcPT_PP7TBranch]+0x23): undefined reference to `typeinfo for ClassA'
libtest_C_ACLiC_dict.cxx:(.text._ZN5TTree16SetBranchAddressI20ClassAEEiPKcPT_PP7TBranch[_ZN5TTree16SetBranchAddressI20ClassAEEiPKcPT_PP7TBranch]+0x3f): undefined reference to `typeinfo for ClassA'
collect2: error: ld returned 1 exit status
this is a stripped down test macro which gives the above error:
#include "myLib/myLibProjectHeaders.h"
#include <TSystem.h>
#include <TChain.h>
#include <iostream>
void libtest()
{
gSystem->Load("myLib/myLib.so");
ClassA* Evt = nullptr;
TChain* mChain = new TChain("Tree1");
mChain->Add("testfile.root");
mChain->SetBranchAddress("BranchA",Evt);
std::cout<<"loaded"<<std::endl;
for(ULong64_t iev=0;iev<mChain->GetEntries();iev++)
{
mChain->GetEntry(iev);
if(iev%20==0) std::cout<<iev<<std::endl;
}
std::cout<<"finni"<<std::endl;
}
Any ideas what i’m doing wrong here?
Thanks in advance.
ROOT Version: 6.16/00
Platform: CentOS 7
Compiler: gcc 7.3.0