Re: Troubles with ClassDef and ClassImp

From: Marcelo Zimbres <mzimbres_at_gmail.com>
Date: Wed, 11 May 2011 11:57:04 +0200


hi Salva, just to easy your job,

in the implementation file MyClass.C you should include the lines:

#include "MyClass.h"

ClassImp(MyClass);

with this change you should be able to compile and generate dictionaries in Cint with .L MyClass.C+. Your file MyTest.C has also an error, you have to remove the line

#include "MyClass.C"

Cheers
Marcelo

2011/5/11 Salvador Marti <Salvador.Marti_at_ific.uv.es>

> Hi
>
> I am trying to save my class in a TFile. I have read the documentation and
> I learned that I need to use the ClassDef and ClassImp in my .h and .C
> files. So far so good.
>
> The trouble is that when I include those lines in my code, then I get an
> error when I compile my files. I even tried in a simple test file and I've
> got exactly the same error.
>
> Well, I compile the code within root with the .x MyTest.C++ command
>
> The .h and .C files are attached.
>
> Thanks for your help. Salva
>
> ------- These is the error message --------------
> root [0] .x MyTest.C++
> Info in <TUnixSystem::ACLiC>: creating shared library
> /Users/smarti/scratch/RootTest/./MyTest_C.so
> dlopen error: dlopen(/Users/smarti/scratch/RootTest/./MyTest_C.so, 10):
> Symbol not found: __ZN7MyClass11ShowMembersER16TMemberInspector
> Referenced from: /Users/smarti/scratch/RootTest/./MyTest_C.so
> Expected in: flat namespace
> in /Users/smarti/scratch/RootTest/./MyTest_C.so
> Load Error: Failed to load Dynamic link library
> /Users/smarti/scratch/RootTest/./MyTest_C.so
> Undefined symbols:
> "MyClass::ShowMembers(TMemberInspector&)", referenced from:
> vtable for MyClassin MyTest_C_ACLiC_dict.o
> "_main", referenced from:
> start in crt1.10.6.o
> "MyClass::Class()", referenced from:
> MyClass::IsA() constin MyTest_C_ACLiC_dict.o
> "MyClass::Streamer(TBuffer&)", referenced from:
> vtable for MyClassin MyTest_C_ACLiC_dict.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
>
>
Received on Wed May 11 2011 - 11:57:15 CEST

This archive was generated by hypermail 2.2.0 : Wed May 11 2011 - 17:50:01 CEST