Re: [ROOT] Global variables and .dll or .so

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Apr 11 2002 - 19:47:12 MEST


Hi Francois-Xavier,

I do not see any problems with your classes. I could not use your
Makefile,
I did the following:

rootcint -f cint.cpp -c TMuster.h TSecond.h LinkDef.h
g++ -fPIC -I$ROOTSYS/include -c cint.cpp  TMuster.cpp TSecond.cpp
g++ -g -Wl,-soname,libMuster.so -shared cint.o TMuster.o TSecond.o -o
libMuster.so

then in a Root session
root > gSystem.Load("libMuster"); 
root > TSecond *s;
root > gM = new TMuster(5);
root > s = new TSecond();
fK = 5

Rene Brun

On Thu, 11 Apr 2002, GENTIT Francois-Xavier  DAPNIA wrote:

>   Dear rooters,
>   I have a problem when using global pointers instantiated within CINT and
> then used in the compiled part of my code, when I create a .dll or .so.  The
> problem nevers appear when I compile my code with a main program and create
> a .exe. Sometimes, not always, the pointer defined by a "new" inside the
> CINT macro appears inside the compiled code to be equal to 0.
> 
>   The pointer is correctly declared in the Linkdef.h file with:
> 
> #pragma link C++ global gM;
> 
>   Is it a rule that when doing a .dll or .so, it is forbidden to use global
> pointers whose memory is allocated within CINT?
> 
>   I join to this mail a very small program to illustrate my point. This
> small program contains 2 (almost empty) classes TMuster and TSecond, plus a
> global pointer gM on TMuster.
> The following CINT macro
> {
>   gSystem.Load("libMuster.dll");
>   TSecond *s;
>   gM = new TMuster(5);
>   s = new TSecond();
> }
> 
>   does the following : the global pointer gM is used inside the constructor
> of TSecond. On Windows, everything works ok, on Linux gM is equal to 0
> inside the constructor of TSecond. I have also cases where the problem
> appears on Windows, unfortunatly, I was not able to condense the problem
> appearing on Windows into a small program.
> 
>   I am using ROOT 3.02/07, Windows NT or Linux.
> 
>   Thanks a lot if you can help me.
> 
>           F.X. Gentit
>           DAPNIA/SPP CEN Saclay
>           tel : 01 69 08 30 38     fax : 01 69 08 64 28
>           web : http://home.cern.ch/~gentit/
> 
>  <<Problem.ZIP>> 
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:49 MET