Loading a Class Dictionary in windows 7

Hi,

I have always programmed in linux before so I am totally new to windows 7 and Visual Studio 2010. I have a visual studio solution that “interacts” with root and creates a root file as defined by a class MyClass.h. In linux, when I want to read the root file I just load the library before in CINT using
gSystem->Load(“MyClass.so”) and it all works fine.
But In windows I only have a .lib file and Load complains that it can not find it or that its not a .dll. But VS 2010 didn’t create a .dll for me and I am sure the path is the right one.
What kind of magic do I have to work here to be able to access my tree?

Thanks a lot in advance.

Berta

Hi Berta,

How did you generate your .lib file?
You have to create a dll (note you can use ACLiC, like on Linux)

Cheers, Bertrand.

Hi Bertrand,

I use Visual Studio 2010 to create a standalone program and create the .exe that we need for our application. To integrate root I do the following in the Project->project name->Property Pages (ALT +F7):

  • Configuration properties-> Linker-> General-> add C:\root\lib
  • Configuration properties-> Linker-> Input -> Add all the root libraries such as libCore.lib, libGUi.lib etc…
  • Configuration properties-> C/C+±>General-> Add C:\root\include
  • Configuration properties -> Build Events -> Pre Build Event-> Command Line
    Add
    rootcint -f fooDict.cxx -c [list of all my .h] fooLinkDef.h
    This is the line that creates my .lib I believe, but I am not so sure, the .lib was there after compilation :slight_smile:

And that is pretty much all. Our executable works very well, but then, when I try to read the tree that we have created from one class I don’t know how to load the needed dictionary. I don’t know how to include the .dll creation in this the scheme, even using ACLIC.

I hope that this answers you question
Thanks again

Berta

Hi Berta,

[quote=“bbeltran”]rootcint -f fooDict.cxx -c [list of all my .h] fooLinkDef.h
This is the line that creates my .lib I believe, but I am not so sure, the .lib was there after compilation
[/quote]Well, this is the line that creates the dictionary… To create a dll for your class (and its dictionary), you should create a dll project including your class source and the dictionary generated with rootcint, or generate a dll with ACLiC. And as you don’t know Visual Studio, I would suggest first to try with ACLiC… (it works the same than on Linux)

EDIT: BTW, you can also maybe take a look at [url=https://root-forum.cern.ch/t/trouble-using-a-dll-with-root/6528/1 post[/url], it shows a nmake makefile for a custom class and how to use it.

Cheers, Bertrand.

Hi Bertrand,

Thanks a lot, I did have a look at the nmake Makefile that you pointed out, and I think that building the solution from the command line in Visual Studio is the option that I want to take from now and on (so far I was building using F7 from Visual Studio). This means that I will have to adapt your Makfile.mcs for my needs. But first things first, I did try to compile the TestUtils.tar.gz that you provide in the post and the command line in Visual Studio (VS->tools-> Visual Studio Command Prompt) gave a an error, see the attached screen capture.
I use Visual Studio 2010, Version 10.0.30319.1 RTMRel
root 5.32/00
and Windows 7 32 bit
Could you help me with the Makefile.mcs options so that I can compile you example TestUtils.tar.gz and from there I should be able to adapt it to my project.

Thanks again for your help

Berta

Hi Berta,

%ROOTSYS%\bin must be in your PATH (bindexplib.exe is in %ROOTSYS%\bin)
And try this Makefile:Makefile.txt (4.9 KB)It has been modified for Visual Studio 2010. Note you can also take a look at %ROOTSYS%\test\Makefile.win32

Cheers, Bertrand.

Hi Bertrand,

Thanks a lot for your valuable help! $ROOTSYS was in my PATH but for some reason bindexplib.exe was not in $ROOTSYS/bin. I did reinstall root and now it all complies perfectly. Now I have to adapt your makefile to my project.

Thanks again.

Berta