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

From: Valeri Fine (fine@bnl.gov)
Date: Thu Apr 11 2002 - 18:21:42 MEST


Hello,

 I got your attachment.

Try to replace your

extern TMuster *gM;

within your  TSecond.h with

R_EXTERN TMuster *gM;

Should help. Cheers Valeri



----- Original Message ----- 
From: "GENTIT Francois-Xavier DAPNIA" <GENTIT@dapnia.cea.fr>
To: "'roottalk@root.cern.ch'" <roottalk@pcroot.cern.ch>
Sent: Thursday, April 11, 2002 9:45 AM
Subject: [ROOT] Global variables and .dll or .so


>   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