Re: [ROOT] new classes
Axel Naumann <Axel.Naumann <at> cern.ch>
2006-07-01 19:29:35 GMT
Hi Mario,
have a look at the Makefile in test, where libEvent is build from
Event.cxx and the dictionary generated on Event.h. You'll need
gcc `root-config --cflags` -c MyClass.cxx
rootcint -f MyClassDict.cxx -c -p MyClass.h MyClassLinkdef.h
gcc `root-config --cflags` -c MyClassDict.cxx
ld `root-config --ldflags` `root-config --glibs` MyClass.o MyClassDict.o
-o test
MyClassLinkdef.h contains
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class TMyClass;
#endif
There's no contradiction between a script and a set of command line
parameters: you can always call
root -l -b -q "MySteeringScript.C(\"whats the question\",42)"
where MySteeringScript.C contains e.g.
void MySteeringScript(const char sentence, int number) {
if (gSystem->CompileMacro("MyClass.C"))
gSystem->ProcessLine(Form("myfunc(\"%s\", %d);", sentence, number);
}
That way you don't have to write a build system, but can immediately
work on code. The build system you're going to come up with is most
probably not the one used when your code goes into production - it's
just for prototyping.
> Also what do I have to do to be able to just add #include "MyEvent.h"
> and then just use the object in any code segment? What kind of
> compilation does that have to be? Is ACLiC compiled .so file enough (if
> it's in LD_LIBRARY_PATH) or do I have to do something else?
The .so file will be enough. Again, in ACLiC you don't have to care, you
just load the lib before you use it.
Cheers, Axel.
> On Jul 1, 2006, at 2:47 AM, Axel Naumann wrote:
>
>
>> Hi Mario,
>>
>>
>> I'm positive that the total time of you reading the part on ACLiC in
>>
>> chapter 7 is less than me copying its content into an email and you
>>
>> reading this email. So why don't you read the users guide, chapter 7.
>>
>>
>> As I'm a nice guy (sometimes
, I even gave you the way to compile
>>
>> your code with root - you probably didn't realize it, though: the ".L
>>
>> ..+" compiles it.
>>
>>
>> If you have to use GCC (trust me, you don't, but you seem not be the
>>
>> listening kind of guy
then look at root-config, which returns the
>>
>> flags you'll need to pass to GCC. And you can check rootcint to build
>>
>> the dict, which you then need to compile and link into a library,
>>
>> together with your compiled code.
>>
>>
>> Or you just read ch7 and use ACLiC.
>>
>>
>> Cheers, Axel.
>>
>>
>> Mario Kadastik wrote:
>>
>>>> root [0] .L MyEvent.cxx+
>>>>
>>>>
>>>> root [1] .L MyTreeCreator.cxx+
>>>>
>>>>
>>>> root [2] createTree()
>>>>
>>>>
>>>>
>>>> would be an example. Move your main into a CreateTree() func in
>>>>
>>>>
>>>> MyTreeCreator.cxx, and you're done.
>>>>
>>>>
>>>
>>> ok, thanks for the response and I will take a look into it with testing
>>>
>>> as well, but just to spare time at this moment can you also tell me what
>>>
>>> do I have to do to actually compile a working binary with the new class
>>>
>>> and my test code? Seems the g++ commands I used didn't quite do the
>>>
>>> trick. I probably have to incorporate the dictionary, but have no
>>> idea how.
>>>
>>>
>>>
>>> --------------------------------
>>>
>>>
>>> Mario Kadastik
>>>
>>>
>>> CMS experiment
>>>
>>>
>>> mario.kadastik <at> cern.ch <mailto:mario.kadastik <at> cern.ch>
>>>
>>>
>>>
>>> "Physics is like sex, sure it may give some practical results, but
>>>
>>> that's not why we do it"
>>>
>>>
>>> --- Richard P. Feynman
>>>
>>>
>>>
>>>
>>
>
> --------------------------------
>
> Mario Kadastik
>
> CMS experiment
>
> mario.kadastik <at> cern.ch <mailto:mario.kadastik <at> cern.ch>
>
>
> "Physics is like sex, sure it may give some practical results, but
> that's not why we do it"
>
> --- Richard P. Feynman
>
>
>