Zig C++ Help With Building using CERN ROOT Libraries

Greetings,

I am attempting to use zig’s build system as a replacement for Makefile in the programs that I use for my research. As I work in hadronic physics, I need to be able to use CERN’s ROOT framework. To this end I perused what I could find and came across this template (which uses zig 0.14.1) for C++ projects that worked perfectly with my simple tests using LorentzVectors, but when I started testing code that used ROOT’s newer DataFrames I have run into issues with undefined symbols in the link step—all of which involved some sort of JIT components. Does zig c++ support compilation with libraries that contain JIT-ted code? The symbols can be seen with nm in /usr/lib/root/libROOTDataFrame.so, but is not found by the linker.

I am not entirely familiar with ROOT’s internals nor that of the Zig build system, so I would appreciate any help I can receive in this matter. (I already deal with shall-we-say interesting code design choices with the other in-house libraries we use at my collaboration’s lab, so I wanted to try out using a build.zig instead of our messy Makefile/CMake/Perl abomination.)

Example error:

error: ld.lld: undefined symbol: ROOT::Detail::RDF::RLoopManager::ToJitExec(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) const
    note: referenced by RInterfaceBase.hxx:204 (/usr/include/ROOT/RDF/RInterfaceBase.hxx:204)
    note:               /home/richardb/src/test/.zig-cache/o/afe1f30980c05e5b7d3376108f094f7d/main.o:(ROOT::RDF::RResultPtr<TH1D> ROOT::RDF::RInterfaceBase::CreateAction<ROOT::Internal::RDF::ActionTags::Histo1D, ROOT::Detail::RDF::RInferredType, TH1D, ROOT::Detail::RDF::RLoopManager, TH1D, 0>(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, std::__1::shared_ptr<TH1D> const&, std::__1::shared_ptr<TH1D> const&, std::__1::shared_ptr<ROOT::Detail::RDF::RLoopManager> const&, int, bool))

The code in question can be found here:

My first instinct is to ask if your local ROOT installation is compiled against (GNU) libstdc++ or (LLVM) libc++? This seems like it might be a mismatch of C++ stdlibs.

I have tried both libstdc++ and libc++ and get the same error, though for what it is worth the ROOT libraries do appear to be compiled with GNU (though ROOT itself uses clang/cling as its backend/interpreter)

So, I managed to fix those errors by manually including either the c++, gcc, or clang .so files, but now it cannot find (maybe because the header doesn’t have a normal name?). Even if I manually copy the file and add it to my project includes it claims it isn’t found.

EDIT:
Managed to fix this, it seems that the build system won’t look through system include directories recursively (using LazyPath) so I had to manually include the relevant paths. However, now I have an uncountable number of errors complaining about certain function references being ambiguous as well declaration conflicts with target of using declaration already in scope. Please see the git repo for details as it is too much to paste here.