Writing to TTree with dictionary while compiling gives some weird errors

ROOT Version: 6.18
Platform: Mint 19.1
Compiler: g++

Hello there everyone!
I keep getting some weird error I can’t understand in any way.
What I’m trying to do is to save some vectors of my custom classes in TTree. In order to do that I’ve made some .h and .cpp files (GConversionPhoton, GEcalPhoton and GLepton) as well as linkdef.h and some .sh script putting those together and creating my Dictionary.cpp and GLib.so file, which then I’m loading with gSystem->Load() into my TestMacro.cpp.
Running .sh script makes no issues, everything works as it should (I guess), same in case of launching TestMacro.cpp via ROOT in interpreter mode. HOWEVER whenever I’m trying to compile it (by adding ++ flag while launching with .x) I keep getting this:

Info in <TUnixSystem::ACLiC>: creating shared library /home/mateusz/Desktop/customClasses/./TestMacro_cpp.so
Warning in cling::IncrementalParser::CheckABICompatibility():
  Possible C++ standard library mismatch, compiled with _GLIBCXX_ '20181206'
  Extraction of runtime standard library version was: '20191114'
cling::DynamicLibraryManager::loadLibrary(): /home/mateusz/Desktop/customClasses/TestMacro_cpp.so: undefined symbol: _ZN7GLepton8StreamerER7TBuffer
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
/home/mateusz/Desktop/customClasses/TestMacro_cpp_ACLiC_dict.o: In function `GLepton::IsA() const':
TestMacro_cpp_ACLiC_dict.cxx:(.text._ZNK7GLepton3IsAEv[_ZNK7GLepton3IsAEv]+0xd): undefined reference to `GLepton::Class()'
/home/mateusz/Desktop/customClasses/TestMacro_cpp_ACLiC_dict.o: In function `GLepton::ShowMembers(TMemberInspector&) const':
TestMacro_cpp_ACLiC_dict.cxx:(.text._ZNK7GLepton11ShowMembersER16TMemberInspector[_ZNK7GLepton11ShowMembersER16TMemberInspector]+0x11): undefined reference to `GLepton::Class()'
/home/mateusz/Desktop/customClasses/TestMacro_cpp_ACLiC_dict.o: In function `GEcalPhoton::IsA() const':
TestMacro_cpp_ACLiC_dict.cxx:(.text._ZNK11GEcalPhoton3IsAEv[_ZNK11GEcalPhoton3IsAEv]+0xd): undefined reference to `GEcalPhoton::Class()'
/home/mateusz/Desktop/customClasses/TestMacro_cpp_ACLiC_dict.o: In function `GEcalPhoton::ShowMembers(TMemberInspector&) const':
TestMacro_cpp_ACLiC_dict.cxx:(.text._ZNK11GEcalPhoton11ShowMembersER16TMemberInspector[_ZNK11GEcalPhoton11ShowMembersER16TMemberInspector]+0x11): undefined reference to `GEcalPhoton::Class()'
/home/mateusz/Desktop/customClasses/TestMacro_cpp_ACLiC_dict.o: In function `GConversionPhoton::IsA() const':
TestMacro_cpp_ACLiC_dict.cxx:(.text._ZNK17GConversionPhoton3IsAEv[_ZNK17GConversionPhoton3IsAEv]+0xd): undefined reference to `GConversionPhoton::Class()'
/home/mateusz/Desktop/customClasses/TestMacro_cpp_ACLiC_dict.o: In function `GConversionPhoton::ShowMembers(TMemberInspector&) const':
TestMacro_cpp_ACLiC_dict.cxx:(.text._ZNK17GConversionPhoton11ShowMembersER16TMemberInspector[_ZNK17GConversionPhoton11ShowMembersER16TMemberInspector]+0x11): undefined reference to `GConversionPhoton::Class()'
/home/mateusz/Desktop/customClasses/TestMacro_cpp_ACLiC_dict.o:(.data.rel.ro._ZTV17GConversionPhoton[_ZTV17GConversionPhoton]+0x1e0): undefined reference to `GConversionPhoton::Streamer(TBuffer&)'
/home/mateusz/Desktop/customClasses/TestMacro_cpp_ACLiC_dict.o:(.data.rel.ro._ZTV11GEcalPhoton[_ZTV11GEcalPhoton]+0x1e0): undefined reference to `GEcalPhoton::Streamer(TBuffer&)'
/home/mateusz/Desktop/customClasses/TestMacro_cpp_ACLiC_dict.o:(.data.rel.ro._ZTV7GLepton[_ZTV7GLepton]+0x1e0): undefined reference to `GLepton::Streamer(TBuffer&)'
collect2: error: ld returned 1 exit status

According to what I’m thinking it looks like I have some issues with ::Streamer(TBuffer&) methods, but I have checked Dictionary.cpp file (containing all needed stuff) and well, they’re there, so I’m a bit confused. I’m attaching all of the files I’m using, maybe the bug (or whatever causes this) is hidden somewhere deeper.
Thanks in advance!
Mateusz

P.S. I’ve checked it on a different system as well and got absolutely the same errors, so I guess it’s not system dependent issue (neither ROOT dependent). customClasses.zip (465.8 KB)

Create a simple “rootlogon.C” file (in your current working directory):

{ // rootlogon.C
  gSystem->Load("GLib");
}
1 Like

Thank you so much! :smiley: Couldn’t believe that was so simple. For my further understanding - what’s the difference between loading it with rootlogon and directly inside my macro?

The difference is that the library is then loaded before ACLiC start parsing and creating the library.
In most case, ACLiC is able to automatically load the required library but in your case you did not generated a rootmap file for the library GLib.so so your root.exe process is not aware of it (it can not autoload it). And any code you may write inside the script would only be executed after the library created by ACLiC is complete … but this stage fails …

Also the note:

  Possible C++ standard library mismatch, compiled with _GLIBCXX_ '20181206'
  Extraction of runtime standard library version was: '20191114'

may indicate that something was not compiled with the same compiler.

The “C++ standard library mismatch” quite often appears on well-maintained systems, where all standard system packages are properly updated, but ROOT binaries (e.g., these provided by the ROOT Team) were compiled some time ago and never “rebuilt”.

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