Xeus-cling and ROOT graphics in notebook

Hello @Sylvain_Corlay and @Axel,

Is it possible to use root graphics in a xeus-cling jupyter notebook?

I have tried the following:

#pragma cling add_library_path("/opt/software/local/stow/root_6.18.04/lib")
#pragma cling load("libCore")
#pragma cling load("libHist")
#pragma cling load("libz")
#pragma cling load("libHist")
#pragma cling load("libRIO")
#pragma cling load("libGpad")
#pragma cling add_include_path("/opt/software/local/stow/root_6.18.04/include")
#include "TH1F.h"
#include "TCanvas.h"
TH1F h1("h1","h1",100,0,1);

Which causes the error in the notebook:

fatal error: malformed or corrupted AST file: 'zlib is not available'

while in the server terminal:

Error in <UnknownClass::InitInterpreter()>: LLVM SYMBOLS ARE EXPOSED TO CLING! This will cause problems; please hide them or dlopen() them after the call to TROOT::InitInterpreter()!



ROOT has its very own Jupyter integration: JupyROOT! It provides ROOT graphics support, see e.g. https://root.cern.ch/notebooks/HowTos/HowTo_ROOT-Notebooks.html and https://github.com/root-project/root/tree/master/bindings/pyroot/JupyROOT

Does that help?

Cheers, Axel.

Hi @Axel,

Thank you. I apologize for my lazily written question. My question is really this; What is needed to use ROOT (ie, draw a canvas) from a xeus-cling C++17 kernel?

The #pragma lines above show how to load libraries. The histogram can be created and manipulated, however, drawing causes the errors above. Is there something with jsroot that needs to be loaded or configured?


I’d prefer to understand whether what you want to do is the best option before answering. Why do you aim to use xeus-cling rather than JupyROOT (which has the graphics support you’re after)?

Hi @Axel,

Fair enough. :slight_smile: These are not critically important questions.

I was wondering if one could use the graphics in xeus-cling with the graphics features of JupyROOT. I suppose the other way around (call the xeus-cling libs from JupyROOT) is a similar question. Sorry if these are naive questions. I am not very familiar with the implementation details of jupyter kernels.

What is the relation between xeus-cling and JupyROOT? Does JupyROOT have every xeus-cling feature or is xeus-cling a very different fork?

This is really a question for @Sylvain_Corlay .


Hello @whit2333 I am sorry I did not respond earlier. I don’t use this forum too much.

I have not tried using the ROOT graphics at all (not so much of a ROOT user per se besides the cling project), but that may be interesting to try out.

The difference between xeus-cling and the Jupyter kernel that is included in cling or the one in the ROOT project is the following:

  • xeus-cling is based on the xeus project which is a C++ implementation of the Jupyter protocol. Xeus is not a kernel but more of a tool to make kernels. It is used at the foundation of a number of Jupyter kernels, including e.g. xeus-python (another Python kernel), xeus-filt, etc…
  • The cling kernel that is included in the cling project uses the “wrapper kernel” approach, that is to inherit from the base Kernel class in ipykernel is built using the implementation of the protocol that is provided in ipykernel. The way this kernel is built is the “wrapper kernel” approach.

Naturally, both are based on Cling.

I think that our approach has some advantages over the wrapper kernel approach and I hope ROOT adopts Xeus eventually for their kernel implementation.

You can read up some of our blog posts on xeus-cling and xeus in general:

The initial announcement for xeus-cling

The announcement for xeus-python

A tutorial on making kernels with xeus

An article on building interactive maps with Jupyter in C++

Another news is that we are working on moving the xeus project to the Jupyter governance and have xeus be a reference implementation of the kernel protocol.

Hi Whit,

I’m lost - I still don’t understand your motivation. You said:

Sure, I understood that. But why? You say “I want to use xeus not JupyROOT. I know JupyROOT can do ROOT graphics, how can I do ROOT graphics with xeus?” I’m asking “then why do you want to use xeus?” and so far I don’t have an answer. If the feature you’re after is in package A but not in B, then maybe you want to use A, not B?

I’m not dissing xeus-cling here, not at all - I can totally see a motivation for kernel implementers - but I don’t see why Whit would benefit from it given the info I have. And yes, I would love to see xeus become part of Jupyter proper, and we might want to migrate JupyROOT on top of xeus at some point. But that is mostly independent from this topic :slight_smile:

Cheers, Axel.

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