Re: [ROOT] Call an user defined function from the interpreter

From: Pierre-Luc Drouin (pldrouin@physics.carleton.ca)
Date: Fri Jun 27 2003 - 18:03:00 MEST


Can I use this compiled function using TMethodCall?

Thanks

Pierre-Luc Drouin

On Fri, 27 Jun 2003, Stanislav Nesterov wrote:

>    Hi,
>    Unfortunately I am aware of this problem: when you are trying to 
> incorporate some external global function from the shared library ROOT 
> sometimes crumbles its arguments. I think this is the problem of 
> incompatibily of some CINT and native data types or the way of schema 
> evolution works (it is only my opinion).
>    The only solution I know is to put the global function into the same 
> file where it is used, i.e. where TMinuit::SetFCN is called, and DON'T 
> generate any dictionary for it. It is also important to declare this 
> function 'extern'. For example you can refer to minuit/src/TFitter.cxx 
> source.
>   
> 
> 		Best regards,
> 				Stanislav.
> On Thu, 26 Jun 2003, Pierre-Luc Drouin wrote:
> 
> > Hi,
> > 
> > Now I can call the function from the interpreter, but the pointers that
> > are passed to the function
> > are not passed correctly. This function is a minimization function for
> > TMinuit, so it has the format:
> > 
> > void (*)(Int_t&, Double_t*, Double_t&f, Double_t*, Int_t)
> > 
> > The problem I have is with the fourth parameter. TMinuit Eval function
> > pass a valid address when it calls the function, but in the function
> > implementation, the address read for the fourth parameter is wrong
> > (0xa) and it causes a segmentation fault. Actually, my LinkDef.h for this
> > function is
> > 
> > ifdef __CINT__
> > #pragma link off all globals;
> > #pragma link off all classes;
> > #pragma link off all functions;
> > 
> > #pragma link C++ function QExtendedLikelihood;
> > #endif
> > 
> > and I produce the corresponding dictionnary file using command:
> > rootcint -f QExtendedLikelihoodDict.cxx -c QExtendedLikelihood.h LinkDef.h
> > 
> > Thanks
> > 
> > Pierre-Luc Drouin
> > 
> > On Thu, 26 Jun 2003, Stanislav Nesterov wrote:
> > 
> > >    Hi,
> > > 
> > >    In this case when generating dictionary add to the LinkDef.h file:
> > > 
> > > #pragma link C++ function MyFunction;
> > > 
> > >    And then proceed as usual, i.e. compiling dictionary, linking, etc.
> > > 
> > > 			Best regards,
> > > 					Stanislav.
> > > On Thu, 26 Jun 2003, Pierre-Luc Drouin wrote:
> > > 
> > > > Hi,
> > > > 
> > > > I've a function (not a class member function) that I want to be able to
> > > > call from the ROOT interpreter. I want a compiled function contained in a
> > > > share library. I'm used to include my classes using
> > > > rootcint and ClassDef, ClassImp statements in my code, but with C style
> > > > functions, I don't really know how to proceed. Suppose my function header
> > > > file is
> > > > 
> > > > =====MyFunction.h====
> > > > #include <cstdio>
> > > > void MyFunction();
> > > > 
> > > > and the source file is
> > > > 
> > > > ====MyFunction.cxx===
> > > > #include "MyFunction.h"
> > > > void Myfunction(){
> > > >   printf("Hello Wolrd\n");
> > > > }
> > > > 
> > > > What should I do if I want to be able to call MyFunction from the
> > > > interpreter, if the function is compiled in a shared library?
> > > > 
> > > > Thanks
> > > > 
> > > > Pierre-Luc Drouin
> > > > 
> > > > 
> > > 
> > 
> > 
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET