TControlBar Function Calling issue

Hello ,

I am trying to develop a standalone application using the TGeom library to display the geometry of a detector to illustrate the hits and tracking of the particles traveling through it. The geometry and tracking isn’t proving to be too difficult but I was trying to make a TControlBar that would control the program and allow for the selection of different entries in the TTree I am reading data from.

When I attempt to call a function from a button I get the following code returned in the terminal:

Error: Function box() is not defined in current scope (tmpfile):1:
*** Interpreter error recovered ***

I have attempted numerous methods to define the function box() which is just a test program for now. I have tried to find previous suggestions I have found online but so far have been unable to correct it. My code is attached below. One interesting thing I noticed is that to exit the control bar I had to use the command “.q”. To me this means the program is dependent on ROOT CINT and isn’t looking for the compiled function but I have no idea how to fix it, but this is just my current thought about it.

int main(int argc, char **argv){
TApplication * theApp = new TApplication(“RichEvent”, 0, 0);
TControlBar *bar = new TControlBar(“vertical”, “Pienu Visualization GUI”,200,10);
bar->AddButton(“Box Geom”,“box()”,“This will make a random Geometry”);
bar->AddButton(“exit”,".q",“This will close the program”);
return 0;

Thanks for you help,


Replace the line:

bar->AddButton("exit",".q","This will close the program"); by


Cameron did you ever solved this and how, I’m having the exact same issue.

Just to clarify, the issue is with the box() function that is not recognized, not the quit call.

You have to generate a dictionary for the box() function. Take a look at this example: box.tar.gz (810 Bytes)

Thanks for the reply. This worked.

I would appreciate (but will understand if you can’t) the procedure to make the box method setupBox below available to the bar:

modified box.h:

#include "Riostream.h"

class box {
	box() = default;

	void setupBox() {
		std::cout << "from global run_me() : Hello!\n";


In LinkDef.h, replace:
#pragma link C++ function box;
#pragma link C++ class box+;

And in box.cxx (showing only the relevant part):

   box *mybox = new box();
   TApplication *theApp = new TApplication("RichEvent", 0, 0);
   TControlBar *bar = new TControlBar("vertical", "Pienu Visualization GUI",200,10);
   bar->AddButton("Box Geom", Form("((box *)0x%ld)->setupBox()", mybox), "This will make a random Geometry");

Cheers, Bertrand.

1 Like

Ah thanks so much Bertrand.

I did have to remove 0x:

bar->AddButton(“Box Geom”, Form("((box *)%ld)->setupBox()", mybox), “This will make a random Geometry”);

After that your solution worked. Thanks so much!


1 Like