Skip to content

Instantly share code, notes, and snippets.

@OChicken
Last active March 8, 2023 20:48
Show Gist options
  • Save OChicken/09b4b4bbc9d6d6e336844a69b65ba9b3 to your computer and use it in GitHub Desktop.
Save OChicken/09b4b4bbc9d6d6e336844a69b65ba9b3 to your computer and use it in GitHub Desktop.
install cling with jupyter support

Cling - ROOT
root-project/cling: The cling C++ interpreter

This installation is implemented in Arch Linux with gcc/g++ 2023 version.

basic installation

git clone http://root.cern/git/llvm.git src
cd src
git checkout cling-patches
cd tools
git clone http://root.cern/git/cling.git
git clone http://root.cern/git/clang.git
cd clang
git checkout cling-patches
cd ../..
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/.local
cmake --build .

This step takes a very long time (at least 7 hours), and memory corrupts (my memory is 20G) in 86% and 88% when cang & clang-cpp are compiling.

The dir build is pretty huge (84G), but we only need these files to make cling function correctly, and remove other files.

cp -rp bin/cling $HOME/.local/bin
cp -rp lib/clang/ $HOME/.local/lib
cp -rp lib/libcling* $HOME/.local/lib
cd ../tools/cling
cp -rp include/cling/ $HOME/.local/include

If your PATH has already set to PATH="$HOME/.local/bin:$PATH", then you can run the command cling in any directory

Run cling (C++) in Jupyter Notebook

cling/tools/Jupyter at master · root-project/cling

Although this link is only support to c++17, however, it still works in c++23 :)

cd src/tools/Jupyter/kernel
mkdir -p  $HOME/.local/share/cling/Jupyter/kernel
cp -rp ./ $HOME/.local/share/cling/Jupyter/kernel
cd $HOME/.local/share/cling/Jupyter/kernel
# below create a cling-cpp23 (actually, use cling-cpp17 does not matter)
cp -rp cling-cpp17 cling-cpp23
vim cling-cpp23/kernel.json    # modify to c++23
vim clingkernel.py             # modify to c++23
# install
pip install -e .
jupyter-kernelspec install cling-cpp23 --user
jupyter-kernelspec list        # check that already installed
# uninstall
jupyter-kernelspec uninstall cling-cpp23
pip uninstall clingkernel
jupyter-kernelspec list        # check that already uninstalled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment