Re: new classes

From: Mario Kadastik <mario.kadastik_at_cern.ch>
Date: Sat, 1 Jul 2006 01:17:38 +0300


Trying to use the library results in this:   $ root -l -b
root [0] gSystem->Load("libparticles.so") dlopen error: /home/mario/pythia/test/./libparticles.so: undefined symbol: _ZTV7MyEvent
Load Error: Failed to load Dynamic link library /home/mario/pythia/ test/./libparticles.so
(int)(-1)
*** Interpreter error recovered ***

Mario

On Jul 1, 2006, at 12:06 AM, Mario Kadastik wrote:

> Hello,
>
> could someone please help me as I'm utterly confused.
>
> I'd like to create a new object to be used in TTree -s. I did
> create the following:
>
> MyEvent.h
> --------------
> #include "TObject.h"
> #include <cstdlib>
> using namespace std;
>
> class MyEvent : public TObject {
> public:
> MyEvent();
> ~MyEvent() {};
> void setNr(Int_t nr);
> Int_t getNr();
> private:
> Int_t nr;
> ClassDef(MyEvent,1)
> };
>
>
> MyEvent.cpp
> ------------------
> #include "TObject.h"
> #include "MyEvent.h"
> #include <cstdlib>
> using namespace std;
>
> void MyEvent::setNr(Int_t nr_new) {
> nr = nr_new;
> }
>
> Int_t MyEvent::getNr() {
> return nr;
> }
>
> MyEvent::MyEvent() {
> nr=0;
> }
>
> ClassImp(MyEvent);
>
> test.cpp
> ----------
> #include "TObject.h"
> #include "MyEvent.h"
> #include <cstdlib>
> #include <iostream>
> using namespace std;
>
> int main(int argc, char **argv) {
> MyEvent * ev = new MyEvent();
> ev->setNr(1);
> cout << "Event nr: " << ev->getNr() << endl;
> return 0;
> }
>
> compiling it results in this:
>
> [oberon] /home/mario/pythia/test > g++ -o libparticles.so -shared -
> rdynamic -O -Wall -fPIC MyEvent.cpp `root-config --cflags --libs --
> glibs`
> [oberon] /home/mario/pythia/test > g++ -o test test.cpp `root-
> config --cflags --libs --glibs` -L$PWD -lparticles/home/mario/
> pythia/test/libparticles.so: undefined reference to `vtable for
> MyEvent'
> /home/mario/pythia/test/libparticles.so: undefined reference to
> `ROOT::GenerateInitInstance(MyEvent const*)'
> collect2: ld returned 1 exit status
>
> what am I doing wrong? I really need just a basic class with some
> objects to use in trees. The trouble is there is no simple example
> I could reference ...
>
> --------------------------------
> Mario Kadastik
> CMS experiment
> 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

"Physics is like sex, sure it may give some practical results, but that's not why we do it"

Received on Sat Jul 01 2006 - 00:17:52 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:59 MET