3

From How to install cling?, I've downloaded the pre-installed binaries for cling-ubuntu on https://root.cern.ch/download/cling/

$ wget https://root.cern.ch/download/cling/cling_2017-03-30_ubuntu16.tar.bz2
$ dtrx cling_2017-03-30_ubuntu16.tar.bz2
$ cd cling_2017-03-30_ubuntu16
$ ls
~/cling_2017-03-30_ubuntu16/$ ls
bin include  lib  libexec  share
~/cling_2017-03-30_ubuntu16/$ cd share/cling/Jupyter/kernel/
~/cling_2017-03-30_ubuntu16/share/cling/Jupyter/kernel/$ ls
build        cling-cpp14  cling.ipynb           clingkernel.py  scripts
cling-cpp11  cling-cpp17  clingkernel.egg-info  __pycache__     setup.py

On the documentation, it says:

pip install -e .

But when it comes to the step:

# register the kernelspec for C++17/C++14/C++11:
# the user can install whichever kernel(s) they

Which C++ version should I use? I didn't have any of those installed? I use gcc to compile my c++ code usually.

And even when I tried installing all with:

jupyter-kernelspec install cling-c++17
jupyter-kernelspec install cling-c++14
jupyter-kernelspec install cling-c++11

The Jupyter notebook shows the kernel but at the home page but when I create a new notebook, the kernel either dies or keeps restarting.

Zanna
  • 69,223
  • 56
  • 216
  • 327
alvas
  • 2,867
  • 10
  • 34
  • 47

2 Answers2

4

I tried your steps and also ran into problems. I had better luck building from source, installing the built kernel, and running with that. I don't have details on your build; make sure you remove any previous kernels from Jupyter before trying this. To do this, based on your input above, use the following commands:

  1. ~/cling_2017-03-30_ubuntu16/share/cling/Jupyter/kernel
  2. jupyter kernelspec uninstall cling-cpp11

Now, here are my build instructions (I'm running Ubuntu 16.04):

  1. mkdir -p ~/builds && cd ~/builds
  2. wget https://root.cern.ch/download/cling/cling_2017-04-15_sources.tar.bz2
  3. tar jxf cling_2017-04-15_sources.tar.bz2
  4. mv src cling_2017-04-15
  5. mkdir -p ~/builds/cling_2017-04-15/build
  6. cd ~/builds/cling_2017-04-15/build
  7. cmake -DCMAKE_BUILD_TYPE=Release ../
  8. make -j8
  9. sudo make install
  10. sudo ldconfig
  11. cd /usr/local/share/cling/Jupyter/kernel
  12. sud pip3 install -e .
  13. sudo jupyer kernelspec install cling-cpp11
  14. cd ~ && jupyter notebook

Now, here's a simple example in Jupyter you can try. Cling is evolving, so check out the doc for the latest syntax.

A simple Cling-Jupyter example.

dgreene
  • 391
  • 3
  • 6
1

There may be a discrepancy in the kernelspec directory naming between those docs and the current code. It seems they now use "cpp" instead of "c++". Using e.g.

jupyter-kernelspec install cling-cpp11

worked better on my cling_2017-03-30_ubuntu16 install.

RLG
  • 11
  • 1