RE: [ROOT] How to export a global from a dll

From: Ed Oltman (eoltman@imago.com)
Date: Tue May 21 2002 - 21:07:49 MEST


Valeri,

I could not export a global.  Here's what happened

I added

	R__EXTERN CAnalysis *gAnalysis

to a class header file (outside the class definition!) and
	CAnalysis *gAnalysis;

to the implementation file.  When I built using a makefile based on the
%ROOTSYS%\test\makefile.win32 I got the warning message:

	warning C4273: 'gAnalysis" : inconsistent dll linkage.  dllexport assumed.

The problem is that the variable is not global! when I try to use it from
within a root session, I get

	Error: Symbol gAnalysis is not defined in current scope

(this is after loading the DLL that contains R__EXTERN..  Here's my
compile switches for file:





    cl  -D_MT -D_DLL -MDd -nologo -G5 -GR -MD -DWIN32 -DVISUAL_CPLUSPLUS -D_
WINDOWS -Ic:\root/include -O2 -c CManage.cpp
Command line warning D4025 : overriding '/MDd' with '/MD'
CManage.cpp






> Hi,
>   How do I export a global variable from a DLL?  I am using VC++6 on Win32
> with root v3.02/07.  Thanks.

  You should  use cpp macro: R__EXTRERN

YourClassHeaderFile.h:
    R__EXTERN  MyClassGolbalVariable *gMyGlobal;


 Look up %ROOTSYS%/include/*.h file for the concrete examples examples
  (See attachment as well)

  Hope this helps. Valeri

>
> Ed Oltman
>
>



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