Jupyter and IPython makes for a very nice notebook, but by default it comes only with Python support. Fortunately, Jupyter supports many kernels, allowing for many languages from R to Redis, Perl to C++ to be supported. Unfortunately though, getting these kernels to run is not exactly an easy business. This time, we will be dealing with cling, a Jupyter kernel for C++.
First, you should install Jupyter. Simply follow the linked instructions.
If you are using Debian 9, I conveniently provide prebuilt binaries for you. Simply download and unpack it, then skip the building instructions.
wget https://raw.githubusercontent.com/root-project/cling/v0.4/tools/packaging/cpt.py chmod +x cpt.py ./cpt.py --last-stable=tar
This will build a tarball in
~/ci/build/. There may be some dependency issues, but you basically need
cmake to finish the process.
If you are unable to build cling for some reason, you can also try their nightly binaries, but they did not work well for me.
Regardless of how you obtained the tarball, you should now unpack it.
If you are using my binaries:
cd <path to>/cling-debian-9.1-x86_64-0.4/share/Jupyter/kernel
And then run:
pip install . jupyter kernelspec install --user cling-cpp14
You will have to configure Jupyter to start with
<path to>/cling-<version>/bin in your
PATH environment variable. Doing this is left as an exercise for the reader.
cling should work with Jupyter. You should see a “C++14” option when creating notebooks or switching kernels in Jupyter.
And of course, nothing is complete without a nice picture: