Repolode
root-project

root-project/cling

An interactive C++ interpreter built on Clang and LLVM, providing a REPL for running C++ code line by line.

Stars
4,201
Forks
313
Open issues
138
Last commit
7 days ago

What is it?

Cling is an interactive C++ interpreter that implements a read-eval-print loop (REPL), so C++ code can be entered and run incrementally without a full compile-link-run cycle. It is built as an extension to LLVM and Clang and reuses Clang's compiler diagnostics.

The project can be built standalone against an existing LLVM/Clang installation, or together with LLVM from a dedicated llvm-project branch. Running the cling binary accepts C++ statements and include directives directly, and it offers dot-prefixed commands such as .help for interactive use.

Cling also supports debugging and profiling of interpreted (JIT-compiled) code through the CLING_DEBUG and CLING_PROFILE environment variables, and it provides a Jupyter kernel that can be installed after building.

Key features

  • 01Interactive REPL for running C++ statements and declarations incrementally.
  • 02Built on Clang and LLVM, reusing Clang's compiler diagnostics.
  • 03Supports #include directives and running code interactively from the command line.
  • 04Debug symbol emission and perf profiling for JIT-compiled code via environment variables.
  • 05Jupyter kernel available for use in notebooks.

Use cases

  • Quickly testing C++ snippets or library APIs without writing a full program.
  • Exploring headers and C++ language behavior interactively.
  • Using C++ in Jupyter notebooks for data exploration.
  • Debugging or profiling code that is JIT-compiled at runtime.

Quick start

  1. 1

    Clone the llvm-project repository and check out cling-latest

    git clone https://github.com/root-project/llvm-project.git
  2. 2

    Clone cling and build it together with LLVM and Clang using CMake

    cmake -DLLVM_EXTERNAL_PROJECTS=cling -DLLVM_EXTERNAL_CLING_SOURCE_DIR=../cling/ -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_TARGETS_TO_BUILD="host;NVPTX" -DCMAKE_BUILD_TYPE=Release ../llvm-project/llvm
  3. 3

    Build the clang and cling targets

    cmake --build . --target clang cling
  4. 4

    Start the interactive interpreter from the build folder

    ./bin/cling

Things to know

  • Building requires compiling LLVM and Clang from source, which is time-consuming.
  • Nightly binary snapshots are currently unavailable, so you must build from source.
  • Some linked documentation and talks are old, and the README notes their stated limitations are outdated.

Topics

FAQ

What is cling?
An interactive C++ interpreter built on Clang and LLVM, providing a REPL for running C++ code line by line. Cling is an interactive C++ interpreter that implements a read-eval-print loop (REPL), so C++ code can be entered and run incrementally without a full compile-link-run cycle. It is built as an extension to LLVM and Clang and reuses Clang's compiler diagnostics.
Is cling free to use? What license does it have?
cling is open source under the Other license. Check the license terms before using it in commercial products.
Is cling still maintained?
Actively maintained. The last commit to cling was on Oct 15, 2026.
What can I use cling for?
Quickly testing C++ snippets or library APIs without writing a full program. Exploring headers and C++ language behavior interactively. Using C++ in Jupyter notebooks for data exploration. Debugging or profiling code that is JIT-compiled at runtime.
How do I install cling?
Clone the llvm-project repository and check out cling-latest: git clone https://github.com/root-project/llvm-project.git Clone cling and build it together with LLVM and Clang using CMake: cmake -DLLVM_EXTERNAL_PROJECTS=cling -DLLVM_EXTERNAL_CLING_SOURCE_DIR=../cling/ -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_TARGETS_TO_BUILD="host;NVPTX" -DCMAKE_BUILD_TYPE=Release ../llvm-project/llvm Build the clang and cling targets: cmake --build . --target clang cling Start the interactive interpreter from the build folder: ./bin/cling
Where can I get cling?
The source code and installation instructions are on GitHub: https://github.com/root-project/cling

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects