In order for my macros to run properly on ROOT, I have to load a library and compile a .cpp file (that defines class functions of a .hpp header). I don’t like to launch ROOT and load both manually everytime with
.L /path/to/lib/library.so
.L /path/to/file.cpp+
so what I have done instead is define an alias in my .bashrc file, which goes like:
alias roott='root -l -L /path/to/lib/library.so -L ~/path/to/file.cpp+'
This all works really well and I am generally happy. However, whenever I launch roott, it takes (and reasonably so) a while to compile (~15 seconds) and sometimes it becomes quite annoying, particularly when I am exiting ROOT to make a small amend and come back in. Is there any workaround that will make things a bit faster?
You can also put the two commands in your rootlogon.C file. file.cpp+ is some C++ code. .L /path/to/file.cpp+ will compile it.
May be compile it once and load the .so as you do for library.so
The .L inside the rootlogon.C does not seem to work. However,
gSystem->Load("/path/to/lib/library.so");
seems to be working flawlessly. This however does not resolve the compilation of the file.cpp. I tried:
gSystem->Load("/path/to/file.cpp+");
and I got:
Error in <TUnixSystem::FindDynamicLibrary>: /home/andreas/ROOTScripts/Classes/Cluster.cpp+[.so | .dll | .dylib | .sl | .dl | .a] does not exist in /cvmfs/sft.cern.ch/lcg/releases/ROOT/6.24.06-20127/x86_64-centos8-gcc11-opt/lib:/cvmfs/clicdp.cern.ch/software/allpix-squared/latest/x86_64-centos8-gcc11-opt/lib:/cvmfs/sft.cern.ch/lcg/releases/LCIO/02.16.01-acee3/x86_64-centos8-gcc11-opt/lib:/cvmfs/sft.cern.ch/lcg/releases/gcc/11.1.0-e80bf/x86_64-centos8/lib:/cvmfs/sft.cern.ch/lcg/releases/gcc/11.1.0-e80bf/x86_64-centos8/lib64:/cvmfs/sft.cern.ch/lcg/releases/binutils/2.36.1-a9696/x86_64-centos8/lib:/cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos8-gcc11-opt/lib64:/cvmfs/sft.cern.ch/lcg/releases/MCGenerators/thepeg/2.2.1-aa9c8/x86_64-centos8-gcc11-opt/lib/ThePEG:/cvmfs/sft.cern.ch/lcg/releases/MCGenerators/herwig++/7.2.1-70ec3/x86_64-centos8-gcc11-opt/lib/Herwig:/cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos8-gcc11-opt/lib/python3.9/site-packages/torch/lib:/cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos8-gcc11-opt/lib/python3.9/site-packages/tensorflow:/cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos8-gcc11-opt/lib/python3.9/site-packages/tensorflow/contrib/tensor_forest:/cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos8-gcc11-opt/lib/python3.9/site-packages/tensorflow/python/framework:/cvmfs/sft.cern.ch/lcg/releases/java/8u222-884d8/x86_64-centos8-gcc11-opt/jre/lib/amd64:/cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos8-gcc11-opt/lib64:/cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos8-gcc11-opt/lib:/cvmfs/sft.cern.ch/lcg/releases/gcc/11.1.0-e80bf/x86_64-centos8/lib:/cvmfs/sft.cern.ch/lcg/releases/gcc/11.1.0-e80bf/x86_64-centos8/lib64:/cvmfs/sft.cern.ch/lcg/releases/binutils/2.36.1-a9696/x86_64-centos8/lib:/cvmfs/clicdp.cern.ch/software/ROOT/6.12.06/x86_64-centos7-gcc8-opt/lib:/cvmfs/clicdp.cern.ch/software/allpix-squared/latest/x86_64-centos8-gcc11-opt/lib:/cvmfs/sft.cern.ch/lcg/releases/LCIO/02.16.01-acee3/x86_64-centos8-gcc11-opt/lib:/cvmfs/sft.cern.ch/lcg/releases/gcc/11.1.0-e80bf/x86_64-centos8/lib:/cvmfs/sft.cern.ch/lcg/releases/gcc/11.1.0-e80bf/x86_64-centos8/lib64:/cvmfs/sft.cern.ch/lcg/releases/binutils/2.36.1-a9696/x86_64-centos8/lib:/cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos8-gcc11-opt/lib64:/cvmfs/sft.cern.ch/lcg/releases/MCGenerators/thepeg/2.2.1-aa9c8/x86_64-centos8-gcc11-opt/lib/ThePEG:/cvmfs/sft.cern.ch/lcg/releases/MCGenerators/herwig++/7.2.1-70ec3/x86_64-centos8-gcc11-opt/lib/Herwig:/cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos8-gcc11-opt/lib/python3.9/site-packages/torch/lib:/cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos8-gcc11-opt/lib/python3.9/site-packages/tensorflow:/cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos8-gcc11-opt/lib/python3.9/site-packages/tensorflow/contrib/tensor_forest:/cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos8-gcc11-opt/lib/python3.9/site-packages/tensorflow/python/framework:/cvmfs/sft.cern.ch/lcg/releases/java/8u222-884d8/x86_64-centos8-gcc11-opt/jre/lib/amd64:/cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos8-gcc11-opt/lib64:/cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos8-gcc11-opt/lib:/cvmfs/sft.cern.ch/lcg/releases/gcc/11.1.0-e80bf/x86_64-centos8/lib:/cvmfs/sft.cern.ch/lcg/releases/gcc/11.1.0-e80bf/x86_64-centos8/lib64:/cvmfs/sft.cern.ch/lcg/releases/binutils/2.36.1-a9696/x86_64-centos8/lib:/cvmfs/clicdp.cern.ch/software/ROOT/6.12.06/x86_64-centos7-gcc8-opt/lib:/cvmfs/sft.cern.ch/lcg/releases/R/3.6.3-e7560/x86_64-centos8-gcc11-opt/lib64/R/library/readr/rcon:/cvmfs/sft.cern.ch/lcg/releases/clhep/2.4.4.0-b903d/x86_64-centos8-gcc11-opt/lib:/cvmfs/sft.cern.ch/lcg/releases/XercesC/3.2.3-714f6/x86_64-centos8-gcc11-opt/lib:/cvmfs/sft.cern.ch/lcg/releases/R/3.6.3-e7560/x86_64-centos8-gcc11-opt/lib64/R/library/readr/rcon:/cvmfs/sft.cern.ch/lcg/releases/clhep/2.4.4.0-b903d/x86_64-centos8-gcc11-opt/lib:/cvmfs/sft.cern.ch/lcg/releases/XercesC/3.2.3-714f6/x86_64-centos8-gcc11-opt/lib:.:/cvmfs/sft.cern.ch/lcg/releases/ROOT/6.24.06-20127/x86_64-centos8-gcc11-opt/lib:/lib64/glibc-hwcaps/x86-64-v4:/lib64/glibc-hwcaps/x86-64-v3:/lib64/glibc-hwcaps/x86-64-v2:/lib64/tls/haswell/avx512_1/x86_64:/lib64/tls/haswell/avx512_1:/lib64/tls/haswell/x86_64:/lib64/tls/haswell:/lib64/tls/avx512_1/x86_64:/lib64/tls/avx512_1:/lib64/tls/x86_64:/lib64/tls:/lib64/haswell/avx512_1/x86_64:/lib64/haswell/avx512_1:/lib64/haswell/x86_64:/lib64/haswell:/lib64/avx512_1/x86_64:/lib64/avx512_1:/lib64/x86_64:/lib64:/usr/lib64/glibc-hwcaps/x86-64-v4:/usr/lib64/glibc-hwcaps/x86-64-v3:/usr/lib64/glibc-hwcaps/x86-64-v2:/usr/lib64/tls/haswell/avx512_1/x86_64:/usr/lib64/tls/haswell/avx512_1:/usr/lib64/tls/haswell/x86_64:/usr/lib64/tls/haswell:/usr/lib64/tls/avx512_1/x86_64:/usr/lib64/tls/avx512_1:/usr/lib64/tls/x86_64:/usr/lib64/tls:/usr/lib64/haswell/avx512_1/x86_64:/usr/lib64/haswell/avx512_1:/usr/lib64/haswell/x86_64:/usr/lib64/haswell:/usr/lib64/avx512_1/x86_64:/usr/lib64/avx512_1:/usr/lib64/x86_64:/usr/lib64
Changing it to:
gSystem->Load("/path/to/file.cpp");
Makes the error disappear, but when I run a file that uses functions defined there, I get an undefined symbol error:
/cvmfs/sft.cern.ch/lcg/releases/ROOT/6.24.06-20127/x86_64-centos8-gcc11-opt/bin/root.exe: symbol lookup error: /path/to/Macro_cpp.so: undefined symbol: _ZN8ClustersC1ESt6vectorIPN6allpix8PixelHitESaIS3_EE