ROOT Version: 6.20.04
Platform: CentOS Linux release 7.9.2009
Compiler: 4.8.5
I find that when I create a shared object library for my own classes which contain other ROOT classes, specifically TLorentzVector, then when I load the library in root it can not find the ROOT class until I create an object of that type.
Here is an example class
test.hxx
#include <TLorentzVector.h>
class test : public TObject
{
public:
test(){};
private:
TLorentzVector x ;
ClassDef(test,1)
};
test.cxx
#include "test.hxx"
ClassImp(test)
test_Linkdef.h
#ifdef __CLING__
#pragma link C++ class test;
#endif
Commands to create shared object library
c++ -O2 -Wall -fPIC `root-config --cflags` -c test.cxx
rootcling -f testDict.cxx -c test.hxx test_LinkDef.h
c++ -O2 -Wall -fPIC `root-config --cflags` -c testDict.cxx
c++ -shared -O2 -m64 test.o testDict.o -o libtest.so
What happens in root:
------------------------------------------------------------------
| Welcome to ROOT 6.20/04 https://root.cern |
| (c) 1995-2020, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for linuxx8664gcc on Apr 01 2020, 08:28:48 |
| From tags/v6-20-04@v6-20-04 |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
root [0]
Processing libtest.so...
cling::DynamicLibraryManager::loadLibrary(): /home/aleph/ajf/t2k/analysis/analyseLowEnergyECalObjects/crazyROOT/libtest.so: undefined symbol: _
Bizarre observation. If I use the name myTest for the class and file names, it works.
This also works:
root [0] TLorentzVector v;
root [1] .L libtest.so
root [2] test z;