Re: [ROOT] ROOT in COM DLL on win32

From: Valeri Fine (Faine) (fine@bnl.gov)
Date: Fri Apr 13 2001 - 20:02:47 MEST


Hello Anton

 First may I ask you to  send us only copy of your message.
 I am (Rene as well) on the roottalk and there is no need sending 
 second copy directly.


> Hi guys,
> 
> thanks for the suggestion. Valery, since you have a lot of experience with
> win, could you comment where and how ROOT initialization should be added in a
> stand-alone dll which uses (internally) ROOT libs and calls?
> 

  Waht about your question it depends what technique to initilze DLL you employ.
  Did you use DLL entry points ?
  It is not ggod amd may lead to some problem to fight with.
 One needs DLL entry unles one uses C++.
 Under C++ one should use the  global variable instead that the run-time system
 must initilaize just one loads the share (DLL) library with no extra manipulation.

 I guess the code (it must be part of your DLL) as follows will make the job:

======================
 class initRoot {
  public:
    initRoot(){
        int argc = 2;
        char *argv[] = {"athena","-b"}; 
        TString extPrompt = "";
        if (!gApplication) {
             fThisApplication = (TApplication *)new TRint("Rint", &argc, argv, 0, 0);
             extPrompt = " [%d] ";
        } else 
            fThisApplication = gApplication;
         static TString prompt =  gSystem->BaseName(gROOT->GetApplication()->Argv(0));
        if (extPrompt != "") {
           prompt += extPrompt;
           // Redefine prompt
           ((TRint*)gROOT->GetApplication())->SetPrompt( prompt.Data()); 
        }
 . . . 
   } 
 void  command(const char *command) const
 { 
   if (command && command[0]) gROOT->ProcessLine(command);
   else fThisApplication->Run(kTRUE);
}
int  load(const char *shareLibName) const 
{  // Load share libraty via ROOT TSystem::Load method
  return gSystem->Load(shareLibName) ;
}
  etc etc etc

};

 TROOT root(...)
 initRoot __starRoot __;

======================

No Windows special here by the way.
May be you will want to create several classes to separate ROOT access and
ROOT instantiation. For example you want the ROOT instantiation to be singleton
etc

 Hope this helps
                    Valeri

> Regards,
> Anton
> 
> Rene Brun wrote:
> 
> > Hi Valery,
> > I would like to correct your statement.
> > We have implemented class member functions such as TLine::SetLineColor
> > or TBox::SetFillColor.
> > However, Microsoft have a huge number of CPP statements like
> >   #define xxxxxx SetLineColor
> >
> > We spent a lot of time understanding why we had unsatisfied references
> >    TLine:xxxxxx
> >
> > This is the way Microsoft is making money !
> >
> > The solution as Valery explained is to undefine what is defined
> > in several Microsoft includes (see Windows4Root.h)
> >
> > Rene Brun
> >
> > On Fri, 13 Apr 2001,  Valery Fine wrote:
> >
> > >
> > >
> > > > Hi rooters,
> > > >
> > > > I am trying to develop a COM dll for MSVC/VB bridge in rquant project.
> > > > The dll should be able to initialize ROOT whenever it is loaded. The
> > > > very first and straightforward try has failed:
> > > >
> > > > after I include TROOT call to DllMain entry point function root starts
> > > > to conflict with MS string definition saying
> > > >
> > > > StrDupA redefinition. c:\root\include\tsrtring.h
> > > >
> > >
> > >
> > > >
> > > > Could you comment on this? Does someone has experience with ROOT in a
> > > > stand alone dll  (com dll)? Any further problems and pitfalls?
> > >
> > >   I believe you faced the "well-known" clash between ROOT and Microsoft.
> > >   It is interesting   occasionally  ROOT team used to choose  the name
> > >   those exactly  match those Microsoft  did for the same purposes.
> > >
> > >   However the Microsoft names are the names of the CPP macros
> > >  (They did this to preserve the backward/forward comatibilitis across
> > >  different platforms).
> > >
> > >  Look up " Windows4Root.h" to see what I am speaking about and to see
> > >  how the problem can be cured
> > >
> > >
> > > >
> > > > Regards,
> > > > Anton
> > > >
> > > > www.smartquant.com
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> 
> 



This archive was generated by hypermail 2b29 : Fri Jun 08 2001 - 11:51:22 MEST