Building custom interpreter in ROOT

Hi,

We used ‘custom CINT’ (CINT built with our proprietary compiled functions) many years ago with older versions of linux (Ubuntu 12.x and earlier). We are now moving to Ubuntu 22.x and would like to similarly build a custom interpreter like we had with CINT.

I was able to download the ROOT source and build it on our platform for simple command line usage to test it out. But I am not finding any similarities in terms of easily building ROOT with our compiled code like I did with ‘makecint’.

We don’t need all the power of ROOT. I think the best way is to use Cling but I am not sure if I am on the right track as I have not found anything that would integrate several source files into the interpreter. Perhaps I am not looking in the right place.

(Chapter: Cling)

Our code is quite extensive with its directory structure and makefiles that will build the dozens of .o files properly. The aim is to integrate the API into the interpreter so that users can write their own scripts with the functions defined in the API.

Where can I find examples/of building Cling with our code? Or is there another solution?

Thank you.


_ROOT Version: v6.26.10
_Platform: Ubuntu 22.04
_Compiler: g++ 11.3.0


Welcome to the ROOT forum.

As you noticed CINT has been replaced by CLING.
You ar on the right track.
You can follow the instructions given here:

I have not made much headway. I was wondering if there is something wrong with my environment (build/installation) or just with my understanding. I am able to do a few things but nothing close to being able to get a single custom interpreter tool (say, ‘myroot’) that would have the ability to run a script that invokes functions that are built into ‘myroot’.

But before I go there, I’d like to know why I get 2 different outputs with the same script/source file if I execute it differently.

mytest.c (737 Bytes)

From the linux command line, when I type

root -l mytest.c -q

my output is :

Processing mytest.c…

Is CINT Defined? - NO
Is CLING Defined? - YES
Is MAKECINT Defined? - NO
Is ROOTCLING Defined? - NO


But when I type

root -l mytest.c++ -q

my output is :

Processing mytest.c…
<msg about creating shared library (no error)>

Is CINT Defined? - NO
Is CLING Defined? - NO
Is MAKECINT Defined? - NO
Is ROOTCLING Defined? - NO


Why the difference in CLING define status?

Thanks.

I get the same on Mac.
@vvassilev should know why the outputs are different.

For me it’s obvious: “__CLING__” is defined in “interpreted code” and not in “(pre)compiled code”.

Yes, that is absolutely right. Additionally, the __CINT__ and __ROOTCLING__ preprocessor macros are defined by rootcling during dictionary generation.

Did you progress with that? If you don’t need any features from ROOT, but just the C++ interpreter services, then you should probably take cling as a (leaner) base.
If you want to use cling as a library from your program, here is an example that can be used as a starting point: cling/tools/demo at master · root-project/cling · GitHub.

Cheers,
J.

OK. I thought both my invocations execute “mytest.c” in the interpreter mode though the one with ++ first creates a library of the source. Without the -q, I’d stay in the interpreter (root prompt).

Thank you.

When I tried doing some things on the lines of the demo, I got several errors of the “not found”, “not defined” nature. For ex., make could not resolve

#include <cling/Interpreter/Interpreter.h>

I can see the above header file in several subdirectories but don’t understand why the path for the right one is not set. On another error, I specified the path (to cmake) with -D and got a warning that “manually specified variables were not used”.

I decided to rebuild cling in case I had missed something the first time. Using this -

I noticed an error on the build instructions. The following line in the second block of commands to confiigure and build cling -

cmake -DCMAKE_INSTALL_PREFIX=[Install Path] -DCMAKE_BUILD_TYPE=[Build configuration, e.g. Release or Debug] …\src

It should be -

cmake -DCMAKE_INSTALL_PREFIX=[Install Path] -DCMAKE_BUILD_TYPE=[Build configuration, e.g. Release or Debug] …/…/src

In the first block of instructions to check out from Git, we cd down 3 levels from top, then cd up 2 levels. We are in “src” where we do mkdir build and then cd build. Now “src” is two levels up.

(Minor bug - there is a mix of forward and back (Windows?) slashes for paths)

I saw something similar while building root.

After my build of cling completes, I will see what I can do and report back. Thank you.

I don’t know why my msg above puts 3 dots in the paths instead of 2. Editing only shows 2 dots.

Could someone point me to the tools for posting on this forum? It does not have some std features I am used to (I am not seeing/finding them). For example, how to quote a post selectively before replying, how to mark something as a code block etc. Is there a way to preview how the post is going to look before I press “Reply”?

When I clicked on the " on the toolbar, it printed “> Blockquote”. No idea what that would do and didn’t want to quote an entire post.

Thanks…

@salz-root In principle, most of the Markdown, BBCode and HTML text formatting should work.

See also: Uncle Google → Discourse code formatting

@jalopezg ,

I downloaded and rebuilt cling.

When I try to build the example project that you pointed me to, I get the same errors that I was getting with my own experiments. I am using the cmake command specified on this page :

cmake -Dcling_DIR=/cling-install-dir/lib/cmake/cling /cling-source-dir/tools/cling/tools/demo

I get error for the CMakeLists.txt file : line 25 (find package)
It says it can’t find a package config file provided by cling with either of these names:
clingConfig.cmake
cling-config.cmake

When I searched, I found:

/cling-install-dir/lib/cmake/cling/ClingConfig.cmake
/cling-build-dir/lib/cmake/cling/ClingConfig.cmake

So, I copied ClingConfig.cmake to clingConfig.cmake in the install-dir and the error went away.

Since the cling config files I found have an uppercase C in the name, I tried -DCling_DIR in the cmake command and got this warning for Cling_DIR -
“manually specified variables were not used by the project”

Is copying the “ClingConfig.cmake” to “clingConfig.cmake” the right way forward?

I cannot see any mention to these files (only to ClingConfig.cmake) neither on master or the v0.9 tag. Which revision have you checked out of the cling repository?

Makes sense; maybe some renaming that happened in the past and that I am not aware of.

So it seems.

Cheers,
J.

My cling version is 1.0-dev

I checked it out and built it using these instructions on Jan 20, 2023.