[ROOT] Using a class from a shared lib

From: Ole Streicher (ole@ifh.de)
Date: Mon Sep 02 2002 - 13:27:02 MEST


Hi!

I want to use a class that is compiled in a shared library for the 
interactive work of Root.

The problem is that Root/Cint seems to not recognize my class. When I
have in the include file

class MyRun {
  private: 
   int Number;
  public: 
   MyRun(int);
};

and I put the appropriate .cpp compiled into the shared lib, I get the
error message:

root [0] gSystem->Load(".libs/mylib");
root [1] .L MyRun.h
root [2] MyRun run(1);
Error: MyRun() header declared but not defined FILE:/tmp/fileAvD17t_cint LINE:1

When I put the "ClassDef" line into the class declaration, I get a
number of mystic linking errors when compiling the class:

/usr/include/g++-3/stl_construct.h:43: undefined reference to `MyRun virtual table'
./.libs/libmyrun.so: undefined reference to `ROOT::GenerateInitInstance(MyRun const *)'
./.libs/libmyrun.so: undefined reference to `MyRun type_info function'
./.libs/libmyrun.so: undefined reference to `MyRun::ShowMembers(TMemberInspector &, char *)'
./.libs/libmyrun.so: undefined reference to `MyRun type_info node'

My LinkDef.h is 

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link off all typedef;
#pragma link C++ nestedtypedef;
#pragma link C++ nestedclass;
#pragma link C++ class pamela::MyRun+;

What is wrong with my code?

Ole



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