This document gives instructions for installing the Xeus-Cling C++ Jupyter kernels in a CoCalc project.
The outline is:
Xeus-Cling provides kernels for Project Jupyter enabling the C++ programming language in the Jupyter notebook.
CoCalc (for "Collaborative Calculation in the Cloud") is a sophisticated online environment for
Due to a minor obstacle, Xeus-Cling is so far not installed system-wide in CoCalc. Solving that is tracked at CoCalc issue #2324. The transition of the default CoCalc image to Ubuntu 18.04 in Summer 2018 can hopefully solve the issue.
In the meanwhile, it is possible to install Xeus-Cling manually in a CoCalc project, following the instructions below.
The solution we propose is to
Open a CoCalc terminal and run the following command in it:
This might change the shell prompt, getting it an extra indication such as
(base) which tells you you are in the base Anaconda environment.
Now run this:
conda create -n boo xeus-cling -c QuantStack
The last step of our installation is to make Jupyter aware of the new kernels, by installing them in the appropriate location.
For this, it suffices to run the following in our CoCalc terminal:
jupyter kernelspec install --user .conda/envs/boo/share/jupyter/kernels/xeus-cling-cpp11 jupyter kernelspec install --user .conda/envs/boo/share/jupyter/kernels/xeus-cling-cpp14
We can now exit Anaconda:
This restores the usual CoCalc terminal prompt.
To test that everything went well, we open a Jupyter notebook worksheet in our CoCalc project.
In the "Kernel > Change Kernel" menu item in the worksheet, we see two new kernels called C++11 and C++14.
(If not, use the "Kernel > Refresh Kernel List" menu item.)
Now change to the "C++11" kernel, which should appear towards the top of the list of available kernels.
Optionally, add a markdown cell to give a title to the notebook.
Then, in a code cell, type some C++11 code, for example:
int i = 1; i + 3
Provided valid C++ code was entered, the output should appear below!
The example above gives:
Thanks to QuantStack for developing the xeus-cling Jupyter kernels for C++11 and C++14!
Exploring this topic as well as writing and publishing this installation guide and example worksheet was facilitated by
CoCalc project upgrades (internet access, member hosting) for development, kindly provided by SageMath Inc.
financial support from OpenDreamKit, "Horizon 2020" "European Research Infrastructures" project #676541.
Thanks to Sylvain Corlay for making the installation one step simpler, after a first version of this document was published.
Thanks to the organisers of the Workshop on interfacing scientific software with low-level libraries, held in Cernay-la-Ville (near Paris, France), 30 April -> 05 May 2018, where a second take on the installation was done, resulting in simpler instructions than the first take which suggested starting by installing Miniconda.
This document is the third take, after CoCalc projects started using a default image based on Ubuntu 18.04.