The advantage of C++ in Deepnote can come in handy when you want faster data processing. If this is your goal, then this guide is for you.
For users looking to work with C++, We've prepared a setup for a C++ kernel in Deepnote using a custom environment. We will provide detailed instructions on setting up and running a C++ kernel in Deepnote, along with tips for troubleshooting common issues.
Setting up the C++ kernel
FROM deepnote/python:3.9
RUN apt-get update && \\
apt-get install -y g++ libtinfo5
RUN pip install jupyter-console
RUN wget <https://root.cern.ch/download/cling/cling_2020-11-05_ROOT-ubuntu18.04.tar.bz2> && \\
tar -xf cling_2020-11-05_ROOT-ubuntu18.04.tar.bz2 && \\
cd cling_2020-11-05_ROOT-ubuntu18.04/share/cling/Jupyter/kernel && \\
pip install -e . && \\
jupyter-kernelspec install --user cling-cpp17
ENV PATH="cling_2020-11-05_ROOT-ubuntu18.04/bin:$PATH"
RUN jupyter console --kernel cling-cpp17
ENV DEFAULT_KERNEL_NAME "cling-cpp17"
Example: Running C++ code
#include <bits/stdc++.h>
using namespace std; //this line is only for noobs xD
short countBits(unsigned int x){
short numBits = 0;
while (x) {
numBits += x& 1;
x >>= 1;
}
return numBits
}
count << countBits(4) <<endl;
// result 1
Please note, in the current version of the kernel, there are some limitations like the inability to define more than one function in a block. However, these are expected to be corrected in future versions of this kernel.
So if you think C++ can be your game-changer, deep dive into Deepnote and start the process.
If you encounter further issues, please get in touch with our support. Happy coding in Deepnote!