Cling, run C/C++ as script

Based on Clang and with the LLVM

Cling, run C/C++ as script

How can IntelliSense from your IDE/Editor know if the code is it right without even compiling? This is possible thanks to cling style technology.

Cling is an interactive C++ interpreter, built on the LLVM and Clang. Its advantages over standard interpreters are that it has command line prompt and uses just-in-time (JIT) compiler for compilation. Many of the developers of these types of software applications call them interactive compilers.

One of Cling’s main goals was to provide a contemporary, high-performance alternative to the first C++ interpreter in the ROOT - CINT project. Backward compatibility with CINT was a top priority during development.


Just download the script Python, give execution permission and run:

chmod +x
./ --check-requirements && ./ --create-dev-env Debug --with-workdir=./cling-build/

The truth is that this construction process will take a long time, the cling is huge! Then see how to install the binary below.

There is binary for several operating systems including Linux . If you want to quickly install on Ubuntu, for example, do as follows:

As of the publication date of this article this is the latest version, for other versions and binaries see here .

wget -q
tar xjf cling_2020-11-05_ROOT-ubuntu2004.tar.bz2
sudo mv cling_2020-11-05_ROOT-ubuntu2004/ /opt/cling
sudo ln -s /opt/cling/bin/cling /usr/local/bin/cling

Testing, run:

cling '#include <stdio.h>' 'printf("Hello World!\n")'

If you want to omit stderr, run:

cling '#include <stdio.h>' 'printf("Hello World!\n")' 2>/dev/null

You can also enter a subshell by just running:


For more usage tips visit the addresses:

cpp cppdaily clanguage