cling goes public!


We, the cling team, have announced cling, our C++ interpreter prototype! (note: its SVN repository has changed compared with the announcement email; see the build instructions)

To a large extend thanks to Vassil's impressive commitment, cling now behaves like a good C++ interpreter: it runs C++ code that's entered, and prints the results.

[cling]$ #include <cmath>
[cling]$ double x = std::sin(3.1)
(double) 4.158066e-02
[cling]$ .L libz
[cling]$ #include "zlib.h"
[cling]$ zlibVersion()
(const char * const) ""
$ echo 'extern "C" const char* zlibVersion();
 zlibVersion()' | cling -lz
(const char * const) ""

We have of course already added a few features that we liked from CINT - but cling is a completely new development, based on clang and llvm, a set of compiler libraries (to simplify the matter a bit :-) Vassil will present the innards of cling probably in October; I will post the slides here.

So what's special about cling? It's based on a production-grade compiler and it's designed taking decades of experience with CINT into account. And it doesn't need dictionaries! (Disclaimer: that does not mean that ROOT can do without, automatically. But that's our goal, of course.)

The next steps will be the ones most relevant for High Energy Physics: integration into ROOT (Paul is already working on that) and reloading of changed code (.x myCode.C, edit, .x myCode.C). That latter part is horrible for a compiler.

If you want to check cling out you can simply compile it yourself - it's really easy. I'd love to have an interactive, web-based interface once, but an online C++ interpreter is an invitation for script kiddies to hack the server :-( If you have an idea how to do it please let me know!


cross build cling for windows 32bit, try to load dll file

I use the cross build toolchian built a cling for windows 32 bits, and modify some source code in CIFactory.cpp (find the include path). the cling.exe can do "printf("test!\n");", but it cannot load the dll file, dose it have any plan to support in windows system?? Thanks, ChuYuan Chiang

Re: cross build cling for windows 32bit, try to load dll file

Hi ChuYuan Chiang,

Thanks for your question! There are two parts. For not being able to load a DLL, that's a bug that you can now follow up in our bug tracker. We might not be able to reproduce the issue; it would be good if you could provide us with more information of how exactly it fails, e.g. by sending the error message to

Windows support is still severely limited: we currently cannot use the newest clang which has much improved "native" Windows C++ ABI support. OTOH, C on Windows should just work. We are planning on getting cling to work with the head of clang's trunk again during the first half of this year.

Cheers, Axel

Hi Axel, Is planned cling to

Hi Axel, Is planned cling to work with Visual Studio 2013 64 bit after the first half of this year ? As far as I understand the current cling version C language should work with Visual Studio 2013 ? Thanks, Vladimir

Re: cling on MSVC 2013 64bit

Hi Vladimir,

Good question! My colleague Bertrand is making lots of progress with Windows support: cling now works with the newest MSVC in C++ mode (with exceptions off)! We currently plan to get ROOT 6 to work with 32bit first and deal with 64bit later.

Cheers, Axel.

How does one build with MSVC

How does one build with MSVC ? Any chance you could tell us some of the steps you/Bertrand did to build the latest cling with MSVC?

Re: How does one build with MSVC


Bertrand has added to the cling build instrucions page to explain how to build cling on Windows.

Cheers, Axel.

cling vs alternatives

Hi, How you would briefly compare cling with alternative projects: Ceemple, Julia, chaiscript ? Thanks, Vladimir

Re: cling vs alternatives

Hi Vladimir,

Well, cling for for C++, to begin with :-) You're welcome to do a proper comparison and post the link here!

Cheers, Axel

Is it possible to redefine

Is it possible to redefine (unload or clean) functions, variables and classes in cling interpretator?

Re: unloading

Hi Andrey,

Thanks for your question! Yes, since recently you can undo declarations; ".undo 2" reverts the two previous declarations.

Cheers, Axel.

windows support

Is there any progress to support Windows ?

Re: Windows support

Hi Vladimir,

Some progress on the clang side, but fundamental things still didn't work last time we tried. I will definitely post once Windows support is there!

Cheers, Axel.

C scripting for Windows until C++ scripting will be available

Is it possible to have fully working C only version for Windows until Clang will properly support Windows C++ ? I mean C scripting from VS C++ ...

Re: C scripting for Windows

Hi Vladimir,

Brilliant idea! Like that it's not useful for ROOT and we cannot run the cling test suite - but at least we can build it! Watch the commit logs for updates - but I suspect that this will not arrive for another month... we are approaching an integration deadline for ROOT and a conference is coming up.

Thanks again for your suggestion!

Cheers, Axel.

Safety idea

There is a similar project called geordi-prime, it's a haskell-based c++ eval irc bot. The only difference is that it cannot keep state. Anyway, it's publicly available on freenode irc (and countless copies are available elsewhere) and it seems its safety measures are more than enough for irc wannabe hackers. The web-based cling could use the same idea to make sure its safe.

The webpage of geordi-prime:

Cling is really great !!! I

Cling is really great !!!

I was able to integrate it in my System on Windows and not I can use C++11 interactively.

Unfortunately there are still some problems with it.
If I try to do following:

#include "my_header.h"

and header includes some other headers that Cling can not find then it will
CRASH in ASTNodeEraser.cpp .

Re: cling on Windows

Hi Devid,

Thanks for trying it out! As we said quite a few times already: cling is not supported on Windows yet. I'm surprised it even starts up. Sorry. This is only going to change next year. We do welcome patches even before, though!

Cheers, Axel

Problem interpreting a function

Hello, I've successfully compiled Cling on Mac OSX and seems to work for simple C++ expressions. However when I try to create a C++ function I have a strange error:
[cling]$ void ff() {
[cling]$ ?   int mm;
[cling]$ ?   mm = 5;
[cling]$ ?   }
input_line_4:2:11: error: expected ';' at end of declaration
 void ff() {
This is expected behaviour or am I doing something wrong ?

Use .rawInput


The preparseing doesn't work yet and defining a function should happen with the meta command:

[cling]! void ff() {
[cling]! ?   int mm;
[cling]! ?   mm = 5;
[cling]! ?   }


build time of cling

Hello, The statement "If you want to check cling out you can simply compile it yourself - it's really easy." sounds interesting ... but the time to build cling is extremely high. It takes round about 12h on dual core machine (2.2 Ghz) ! Is there a way to get a binary version for i386 LINUX ? --Armin

Re: Build time

Hi Armin,

No way does it take 12h, something must be terribly wrong with your setup. It should take < 30 minutes even on a laptop. Nevertheless you can pick up a binary version of cling here: Don't be scared by the invalid SSL certificate: it's the best CERN can give to us...

Cheers, Axel

clang/cling for Windows 32/64 - is there any progress ?

Is there any progress in supporting Windows 32/64 by clang/cling ? I cannot wait when I could start with cling on Windows platform :-)

Re: Win progress

Hi Vladimir,

Not that I am aware of. We will only get to that next year - unless someone else contributes patches before.

Cheers, Axel.

minor windoze build issue

is the export definition outdated? _ZN4llvm11raw_ostream5writeEPKc* -> _ZN4llvm11raw_ostream5writeEPKcj _ZN4llvm5APInt12initSlowCaseEj* -> _ZN4llvm5APInt12initSlowCaseEjyb _ZTVN4llvm16JITEventListenerE -> _ZN4llvm16JITEventListenerD2Ev _ZN4llvm15SmallVectorBase8grow_podE* -> _ZN4llvm15SmallVectorBase8grow_podEjj dunno about * but gcc refuse that and when build llvm as shared library, cling throw local_cxa_atexit symbol unresolved or something during startup. static library of llvm doesn't cause this

Re: minor windoze build issue


Okay, so you are building with GCC on Windows - which one, MingW or cygwin? None of that has ever been tried to my knowledge, and it's unfortunate that the linker doesn't cope with the exports table.

The local_cxa_atexit symbol might not even be needed when building with GCC. Could you open a bug report at I cannot promise that this will get fixed soon, foryhour configuration, but I would nonetheless like to have a reminder that this issue exists.

For now you are much better off building cling on Linux or MacOS. Take a virtual machine and off you go!

Cheers, Axel

I'm sorry but i'm total noob

I'm sorry but i'm total noob at linux Axel :) I dunno why, everytime i try linux it took less than a day to make me revert to windoze XP :D I use gcc 4.6.3 mingw/msys. you mean that wildcard supposed to resolved by the gcc's linker?

Re: mingw build


Sorry - if you cannot get it to work on Windows yourself you're out of luck for now... We will attack cling on Windows only next year.

Cheers, Axel.

Hi Axl, I build latest cling

Hi Axl, I build latest cling for windows, apparently load module .L doesn't work as expected (in the example) [cling]$ .L libz input_line_6:1:10: fatal error: 'libz' file not found #include "libz" Load file failed. I have put zlib.dll zlib.dll.a zlib.a in current folder. Even set LLVM_LIB_SEARCH_PATH doesn't help. More importantly why it treated as #include "libz"? Thank you Axl, cling is great for learning!

Re: libz on Windows


"zlib" and "libz" are not the same words :-) Try to rename it to libz.dll, or try .L zlib. And please remember that Windows support is still limited for cling due to clang not fully supporting the Windows C++ API yet.

I'm happy to hear that you like cling, even though you take the rocky Windows road!

Cheers, Axel

This time I tried diagnose it

This time I tried diagnose it with filemon (lowlevel filesystem API monitoring), cling first try exact keyword, then add prefix lib and suffix .a if not found if I use .L libz and cling found static/import library it will complain "Bad image" so I assume it's libz.dll that asked? tried .L zlib.dll and cling found it but throw

Re: Windows dlopen


Sorry, we'll be able to help with the Windows build only next year.

Cheers, Axel.

Syntax Error

After I use the make command in the build directory I get this error. I am trying to compile cling. SyntaxError: invalid syntax make[2]: Entering directory `/home/ryan/Documents/build/tools/cling' llvm[2]: Updating Makefile make[2]: Leaving directory `/home/ryan/Documents/build/tools/cling' svn: '/home/ryan/Documents/llvm' is not a working copy File "", line 1 if >= : print "skip" ^ Any help would be appreciated. Thank You.

Re: Syntax Error


Can you submit a bug report at, giving the full build log and the output of "svn diff /home/ryan/Documents/llvm"? My suspicion in that you moved / renamed directories after configuring...

Cheers, Axel


I have built clang/llvm but clang++ doesnt seem to work and i think it could potentially be due to the fact that clang++ only works with mac os as far as i know..could i still run cling if clang++ doesnt work...just to clarify clang works perfectly and it compiles my c code flawlessly just clang++ doesnt work. I am using ubuntu 10.04 Thanks!

Actually clang++ works just

Actually clang++ works just fine on Linux, have a look at this article:

Re: clang++


Please discuss clang issues at the clang mailing list

Cheers, Axel.

"LastKnownGoodSVNRevision" of cling for ROOT?

Hello, since i get some errors both during linking (of rootcling_tmp; gives undefined symbol _ZTVN5clang13PragmaHandlerE, though is on the path) and compiling (no matching function for call to ‘cling::Interpreter::createUniqueName()’) of ROOT with cling enabled, is it possible to have smth similar to cling's LastKnownGoodLLVMSVNRevision.txt in ROOT?
i.e. some way of telling which revision of Cling does the currently checked-out ROOT revision compile (and link) with?


Re: cling and ROOT

Hi Constantin!

Thanks for your question. cling is now distributed as part of ROOT, so there cannot be any revision mismatch.

I have updated the build instructions - maybe it's now clearer that one should not build cling next to clang if using ROOT. And I assume that's what's happening in your case, because you seem to have an old libCling used by a new rootcling.

Also, please submit bug reports like this to Savannah, that help's us triaging them properly. Thanks!

Cheers, Axel

osx link issue

Any help much appreciated: llvm[4]: Linking Debug+Asserts Shared Library libcling.dylib Undefined symbols: "llvm::APInt::initSlowCase(unsigned int, unsigned long, bool)", referenced from: -exported_symbol[s_list] command line option "cling::Interpreter::executeFile(std::basic_string, std::allocator > const&)", referenced from: -exported_symbol[s_list] command line option

Re: link issue


Thanks for your report - should be fixed! But please future report bugs at our bug tracker.

Cheers, Axel.

Thanks for the fix. I'll use

Thanks for the fix. I'll use your bug tracker in the future. I wasn't certain that it was a bug and not just something missing on my end. I still get one undefined symbol with latest SVN: "cling::Interpreter::createUniqueName()", referenced from: -exported_symbol[s_list] command line option

Re: bug tracker


Thanks for your reports; these things just happen because we still haven't integrated cling into our continuous integration system. I assume it was you who submitted this as a bug on savannah, that's really helpful, thanks a lot!

Cheers, Axel

osx link issue

What would cause this after clang builds fine: llvm[4]: Linking Debug+Asserts Shared Library libcling.dylib Undefined symbols: "llvm::APInt::initSlowCase(unsigned int, unsigned long, bool)", referenced from: -exported_symbol[s_list] command line option "cling::Interpreter::executeFile(std::basic_string, std::allocator > const&)", referenced from: -exported_symbol[s_list] command line option "cling::Interpreter::loadFile(std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const*, bool)", referenced from: -exported_symbol[s_list] command line option "cling::MetaProcessor::process(char const*)", referenced from: -exported_symbol[s_list] command line option (maybe you meant: cling::MetaProcessor::process(char const*, cling::Value*))

Re: link issue


Thanks for your report - should be fixed! But please future report bugs at our bug tracker.

Cheers, Axel.

cling.exe hangs up ...

I use win32 compiled cling.exe, it hangs up in the simplest cases: int i=1; - OK int i=1 - without ";" - hangs up ++i; - OK ++i - hangs up #include "stdio.h" - OK #include "math.h" - hangs up #include "math_not_exist.h" - OK, informs about error What going wrong in these cases ? Thanks, Vladimir

Re: cling on Windows

Hi Vladimir,

Thanks for your report! C++ on Windows is still only rudimentary supported by clang. And cling depends on clang. The available features have already much improved over the last few months - but e.g. the ValuePrinter template instantiation (needed to print the value of the expression when omitting the ';') still causes an infinite loop on Windows. That's Vassil's diagnosis.

As templates are pretty fundamental for C++, and as work on the Windows C++ ABI has been picked up recently, there is hope that this will get fixed in the near future. We at CERN also need cling to work on Windows...

On Windows, today, cling should work in C-mode (cling -x c).

Cheers, Axel

Hi Axel, I'm a bit confused.

Hi Axel, I'm a bit confused. Please clarify what options I have now to use cling in production win application ? As far as I understood in both win32 and win64 cases I can use C language only (until clang will fully support C++ in win32 and win64). It means that I should write C wrappers for C++ DLLs and any C++ code that I want to embed ? Another critical issue, you wrote that there is a critical bug that will be fixed in the nearest 4 weeks - cling sometimes crashes in the end of parsing... Is it applicable for win32/win64 C too ? Thanks, Vladimir

Re: cling on Windows

Hi Vladimir,

As I said, I expect cling on Windows to only work in C mode for the time being. The other bug will affect cling on Windows, too, whether C mode or not - it's about input buffer handling which is the same everywhere. I hope that clarifies the situation. As it is right now I would not recommend cling for production use on Windows. But I cannot predict how long it will take clang to support (most of) Windows C++ ABI: could be months, could be days.

Cheers, Axel

"using namespace std" and c++11 lambdas don't work?

On MacOSX 10.6.8, on on llvm/clang svn r150068; on cling svn r43013, with the patch below to cling/lib/Interpreter/DynamicLookup.cpp:419 to get compilation, I'm getting a crash when I do "using namespace std".
$ ./cling
**** Welcome to the cling prototype! ****
* Type C code and press enter to run it *
* Type .q, exit or ctrl+D to quit       *
[cling]$ #include iostream   // NB: the html wouldnt let me send angle brackets around iostream, but they were there!
[cling]$ using namespace std;
Declaration name has no FETokenInfo
UNREACHABLE executed at DeclarationName.cpp:339!
Illegal instruction

$ cd ~/pkg/llvm-post-3.0-svn/llvm/tools/cling/lib/Interpreter

# patch previously mentioned... to get compilation.
$ svn diff
Index: DynamicLookup.cpp
--- DynamicLookup.cpp	(revision 43039)
+++ DynamicLookup.cpp	(working copy)
@@ -416,7 +416,7 @@
           // resolution of the constructors and then initializes the new
           // variable with it
 	  ExprResult InitExprResult 
-	    = m_Sema->ActOnParenListExpr(m_NoSLoc,
+	    = m_Sema->ActOnParenOrParenListExpr(m_NoSLoc,

...also the C++11 lambda feature doesn't seem to work; any clue why? (see below for example)



$  ./cling -Wc++11-extensions

**** Welcome to the cling prototype! ****
* Type C code and press enter to run it *
* Type .q, exit or ctrl+D to quit       *
[cling]$ #include 
[cling]$ using std::cout
[cling]$ auto func = [] () { cout << "Hello world"; };
input_line_6:2:2: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
 auto func = [] () { cout << "Hello world"; };
input_line_6:2:14: error: expected expression
 auto func = [] () { cout << "Hello world"; };

Re: using namespace std

Hi Jason,

I have converted your comment into this bug report. Thanks! Note that it does work if you toggle to .rawInput for the using directive using namespace std; - but that's just a woraround.

The mismatch in DynamicLookup.cpp should get fixed later.

Cheers, Axel