RE: [ROOT] Using dll in win32 application

From: Ed Oltman (eoltman@imago.com)
Date: Fri Aug 02 2002 - 15:59:08 MEST


Valeri,
 I DID build my DLL using %rootsys%\test\makefile.win32 - and the DLL works
fine from within root (e.g. I type .L analysis.dll and have full access to
all of my classes)

My question is, how can I use this same DLL in a stand-alone Win32 program
(that calls root library functions)?  I tried the obvious - adding the .lib
file to the stand-alone program's project, but that does not work - I get
the linker error shown.  Even if I don't try to use the global variable, I
still get linker errors.

My dll contains the class CAnalysis.  The following simple stand-along
program:

#include "TApplication.h"
#include "CAnalysis.h"

int main(int argc, char* argv[])
{
	TApplication *app = new TApplication("App",&argc,argv);
	CAnalysis *pAn = new CAnalysis();
	return 0;
}
causes the following linker error:

test.obj : error LNK2001: unresolved external symbol "public: __thiscall
CAnalysis::CAnalysis(void)" (??0CAnalysis@@QAE@XZ)
Debug/test.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

IS there a name mangling going on?  Thanks..

Ed

> -----Original Message-----
> From: Valeri Fine [mailto:fine@bnl.gov]
> Sent: Friday, August 02, 2002 8:08 AM
> To: Ed Oltman; Roottalk@Pcroot. Cern. Ch
> Subject: Re: [ROOT] Using dll in win32 application
>
>
> Yes, you can.
> But you should take care to link your code against of the so-called WIn32
> "export" library.
>
> Check %ROOTSYS%\test\MAkefile.win32
> to see how this library can be created and used.
>
> Hope this helps, Valeri
>
> -----Original Message-----
> From: Ed Oltman <eoltman@imago.com>
> To: Roottalk@Pcroot. Cern. Ch <roottalk@pcroot.cern.ch>
> Date: 1 августа 2002 г. 23:56
> Subject: [ROOT] Using dll in win32 application
>
>
> >Hello,
> >
> > I have been using a win32 dll that I created using rootcint +
> >compiler/linker. I have been using this dll from within root for
> some time
> >now (root 3.02/07, VC++ 6.0 on win2K) - everything works fine.  Here's my
> >question: Is it possible to use this same dll from a stand-alone win32
> >program?
> >
> >I've tried the following:
> >
> > I added the .lib file that VC++ when I built my dll to my new
> stand-alonge
> >project.  The DLL exports a global variable:
> >
> > R__EXTERN CAnalysis *gAn;
> >
> >and I have this same line in my stand-alone program.  I get the following
> >linker errror:
> >
> >
> >Summary.obj : error LNK2001: unresolved external symbol "public:
> __thiscall
> >CAnalysis::CAnalysis(void)" (??0CAnalysis@@QAE@XZ)
> >
> >
> >Note 1: when I use rootcint, I use a linkdef.h file that contains
> >
> >#ifdef __CINT__
> >#pragma link off all globals;
> >#pragma link off all classes;
> >#pragma link off all functions;
> >#pragma link C++ class CManage;
> >#pragma link C++ class CAnalysis-;
> >           .
> >           .
> >           .
> >#pragma link C++ global gAn;
> >#endif
> >
> >Note 2: In my DLL project, I have a class CManage which contains
> >
> > CAnalysis *gAn
> >
> >in the implementaion file and
> >
> > R__EXTERN CAnalysis *gAn;
> >
> >in the .h file.  When I build the DLL, I get the warning message:
> >
> >LINK : warning LNK4049: locally defined symbol ""class CAnalysis * gAn"
> >(?gAn@@3PAVCAnalysis@@A)" imported
> >
> >perhaps this is a hint...
> >
> >Thanks,
> >
> >Ed Oltman
> >
> >
>
>
>
>



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