Compiling gui tutorial examples

Hi everyone,
I’m trying to compile root tutorial programs in order to run them as shell commands.
I tried the way I use to compile macros: g++ name.C -o name root-config --glibs --cflags --libs
of course after changing the name of the main function in the macro to int main() .
It didn’t work (I should have known it wouldn’t be that easy) . With the file “listBox.C” located in $ROOTSYS/tutorials/gui/ , I get this error :

/tmp/ccrKvOh5.o: In function MyMainFrame::IsA() const': listBox.C:(.text._ZNK11MyMainFrame3IsAEv[MyMainFrame::IsA() const]+0xf): undefined reference toMyMainFrame::Class()’
/tmp/ccrKvOh5.o:(.rodata._ZTV11MyMainFrame[vtable for MyMainFrame]+0xe8): undefined reference to MyMainFrame::ShowMembers(TMemberInspector&, char*)' /tmp/ccrKvOh5.o:(.rodata._ZTV11MyMainFrame[vtable for MyMainFrame]+0xec): undefined reference toMyMainFrame::Streamer(TBuffer&)’
/tmp/ccrKvOh5.o:(.rodata._ZTV11MyMainFrame[vtable for MyMainFrame]+0x2d4): undefined reference to non-virtual thunk to MyMainFrame::ShowMembers(TMemberInspector&, char*)' /tmp/ccrKvOh5.o:(.rodata._ZTV11MyMainFrame[vtable for MyMainFrame]+0x2d8): undefined reference tonon-virtual thunk to MyMainFrame::Streamer(TBuffer&)'
collect2: ld returned 1 exit status

the only thing I changed is the name of the main function.
What am I missing? I looked over the net to find a tutorial on how to compile those macros but i couldn’t find out any help.


Hi Max,

You cannot create an executable this way. The error tells you that the dictionary is missing for the class MyMainFrame.
I would adise to compile with ACLiC doing
root [0] .x listBox.C+
root[0].L listBox.C+


The problem is that i’m trying to compile them in order to run the program from shell, not from root.
The way you suggest works if I work within root, or am I wrong?

Yes, it works inside root. to see how to compile an application, please take a look at $ROOTSYS/test directory, there are many examples.

mmm…i had a look at it, but it’s not so self-explaining. I found the makefile example, but it’s 470 lines long and i am not able to find out where the important parts are. I
Isn’t there a standard procedure to build an executable from a program containing gui? Sorry for bothering, but I can’t really figure it out…
Thanks again ,


Please take a look at this one…

– Bertrand.
Makefile.txt (1.52 KB)

What about just doing: bash $> root.exe -b -q -l listbox.C+