Help with AddExec

Hi, I’m wirting a ROOT GUI program and I want to compile it to run. I look at the DynamicSlicec.C and copy the method like
fCanvas->AddExec (“name”,“PeakPoint()”);
The program can compiled but don’t work as I expected. when I move the mouse the Error is :
Error: Function PeakPoint() is not defined in current scope (tmpfile):1:
*** Interpreter error recovered ***
Could anyone have a ideal what’s the problem?
Thanks.

It is likely that you forget to generate a dictionary for your code.
When you call AddExec your function PeakPoint must be accessible from
the interpreter.
If you do not understand what I am talking about, send the shortest possible ,but running piece of code, we will add the relevant bits to create a dictionary.
or, if you are in a rush, look at the Users Guide.

Rene

Thank you very much for you kind reply.
I copy some lines from the Makefile of ROOT/test directory and solve the problem.
Thank you.

[color=blue]It is likely that you forget to generate a dictionary for your code.
When you call AddExec your function PeakPoint must be accessible from
the interpreter.
If you do not understand what I am talking about, send the shortest possible ,but running piece of code, we will add the relevant bits to create a dictionary.
or, if you are in a rush, look at the Users Guide.

Rene [/color]

Hello,
I do have exactly the same problem as chenlition:
The function added by AddExec can not be found. However, I do not compile my macro with external compiler but I compile it only with ACLIC (.x macro.cxx+). Is there any way to make the dictionary in this mode (without compiling standalone application using makefile?)

Thank you!
OldA

If you compile via ACLIC, the dictionary for your functions is automatically generated. You should be able to invoke one of these functions from AddExec.
Could you send the shortest possible RUNNING setup that we can use to reproduce your problem?

Rene

Hello Rene,
you are right, my situation is sligtely different: I have a script which is usisng AddExec. Exec function is defined in the same file. This represents attached file exectest.c. Here everything is working fine.
This script can be executed separatedly. But I need to include it in my GUI (represented by mainexec.cxx) and here becomes the problem when trying to compile by ACLiC.

See attachments
OldA
mainexec.cxx (57 Bytes)
exectest.cxx (712 Bytes)

Hi,

ACLiC will only generate the dictionary for the items defined in the script itself or a header file with the same name (and a header extension and that is actually included by your script).

So in your mainexec.cxx case, ACLiC has no way to guess that you also want the dictionary for the item in exectest.cxx (There is nothing we can do about, by default, otherwise, you would get the dictionary for everything included in your script (including /usr/include :slight_smile: ).

So you need to either load the 2 files separately via ACLiC or explicitly request the dictionary for what you want:#ifdef __MAKECINT__ #pragma link C++ function ExecFnc; #endifwhich can be added to either exectest.cxx or mainexec.cxx

Cheers,
Philippe

It works fine, thank you!

OldA