How to use libCling.so in other c++ project


Please read tips for efficient and successful posting and posting code

_ROOT Version: v6-34-02@v6-34-02
_Platform: ubuntu 24.04
_Compiler: gcc


Hello, I’m new to ROOT, I just used the root-docker for a few weeks. I found there’s a /opt/root/lib/libCling.so file, it looks like the c++ interpreter engine.

I’m wondering if it’s possible to use it in other c++ project, like linking to libCling.so and interpreting c++ source code, thanks!

Welcome to the ROOT Forum!
I guess so, in principle. But I think @hahnjo knows better if it’s straight forward

Hi @jerryjin, yes in principle you can just link against libCling.so from a ROOT installation. You can also build Cling standalone, outside of ROOT, in case this is more convenient. Depending on your needs, there’s also the “upstream version” of Cling called Clang-Repl. You will get it with any recent installation of LLVM and Clang, and it’s already quite capable, so maybe that already addresses your needs.

1 Like

thank you @hahnjo and @bellenot

1 Like