Standalone ROOT Terminal / Cling Interpreter in C++ CMake project

When integrating ROOT libraries in a standalone C++ CMake project, I sometimes miss the flexibility that the scripts and cling interpreter gives you.

I had the idea of porting the official ROOT GUI tutorial tutorials/guiWithCINT.C into a CMake project. The tutorial opened with root works fine.

However, in the CMake version, it only works if I remove the function prompt = ((TRint*)gROOT->GetApplication())->GetPrompt(), otherwise it gives an error. Has someone an idea on how to avoid this error without needing to remove this function?

Another issue I have seen is that the ‘X’ of the window does not call CloseWindow any more in the standalone version, while in the other it does.

Attached are my project files.
CMakeLists.txt (993 Bytes) main.cxx (429 Bytes) MyTerminal.cxx (3.2 KB) MyTerminal.h (1.6 KB)

Ok, it looks like the class TGCommandPlugin takes care already of the first error:

TString sPrompt = "root []";
TApplication *app = gROOT->GetApplication();
if (app->InheritsFrom("TRint"))
    sPrompt = ((TRint*)gROOT->GetApplication())->GetPrompt();

Still not sure about the second error (‘X’ button not working)

Hi @ferhue - regarding the first issue, I suspected something along these lines, glad you found that one out!

I have invited @bellenot to have a look at the second issue you mention.

1 Like

Remove this line (in MyTerminal.h):

    RQ_OBJECT("MyTerminal")  ///< for classes not derived from TQObject, RQ_OBJECT macro should be used

This macro is for classes not derived from TQObject (as mentioned in the comment :wink: )

1 Like

Ahh, well seen, solved! Thanks :).

1 Like