Re: rootcint and inlines

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Sep 09 1999 - 19:48:19 MEST


Hi Damir,
As already correctly reported by Philippe, you forgot the implementation
file
for your class VOptions. I tried your simple example with no problems at
all.
What you get with nm is correct.
The code for the Undefined functions is not in the dictionnary
but in the implementation file.
Run the following script:

rootcint -f cintdamir.cxx -c VOptions.h damirLinkDef.h
g++ -fPIC -I$ROOTSYS/include -c cintdamir.cxx VOptions.cxx
g++ -g -Wl,-soname,damir.so -shared cintdamir.o VOptions.o -o damir.so

with the files
//VOptions.h
//==========
#include "TNamed.h"

class VOptions : public TNamed
{
public :
   void              Copy(TObject& obj);

   ClassDef(VOptions,1)  // General options used in a VEGA session
};

//VOptions.cxx
//============
#include "VOptions.h"
   
   ClassImp(VOptions)
   
void VOptions::Copy(TObject &obj)
{
}

//damirLinkDef.h
//==============
#ifdef __CINT__

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class VOptions;

#endif


Rene Brun


On Thu, 9 Sep 1999, Damir Buskulic wrote:

> Hi,
> 
> I have a problem that I'm not able to handle alone. It goes down to this
> very simple case. Consider the header file below that gives me trouble :
> =====================================================================
> #include "TNamed.h"
> 
> class VOptions : public TNamed
> {
> public :
>    void              Copy(TObject& obj);
>    ClassDef(VOptions,1)  // General options used in a VEGA session
> };
> =====================================================================
> 
> Simple (and simplified) indeed. When one tries to run rootcint on it, 
> 
> [toto]$ rootcint -f options.cc -c -I$ROOTSYS/include VOptions.h
> LinkDef.h
> 
> The linkdef file is given below. Then, compile the produced file :
> 
> [toto]$ g++ -g -fPIC -fno-rtti -fno-exceptions -I$ROOTSYS/include -c
> options.cc
> 
> And see the symbols defined with
> 
> [toto]$ nm -C options.o | grep VOptions
>                  U VOptions::DeclFileLine(void)
>                  U VOptions::DeclFileName(void)
> (among other things).
> So, the inline DeclFileLine is not defined. When I link the rest of my
> program, I end up with complaints from the linker about undefined
> references to `VOptions virtual table` and `VOption::DeclFileLine(void)`
> 
> Now the point is that if I remove the derivation from TNamed OR use a
> method Copy() instead of Copy(TObject& obj);, there is no more warning
> and everything goes OK, but it's not what I want.
> There was an explanation some time ago about such inline problems. Is it
> possible to make rootcint generate code that will force the compiler to
> do the right thing (what ever that means)
> 
> By the way, I tried everything I could imagine (put constructors, move
> normal inlines around, etc...). Is there a way out of this ? Force some
> other part of the code to use this class ? Make a special ClassDef
> without inlines ?
> 
> Sorry for this long message
> 
> Damir
> 
> ==========================LinkDef.h
> #ifdef __CINT__
> 
> #pragma link off all globals;
> #pragma link off all classes;
> #pragma link off all functions;
> 
> #pragma link C++ class VOptions;
> 
> #endif
> =====================================
> 
> -- 
> =====================================================================
> | Damir Buskulic                  | Universite de Savoie/LAPP       |
> |                                 | Chemin de Bellevue, B.P. 110    |
> | Tel : +33 (0)450091600          | F-74941 Annecy-le-Vieux Cedex   |
> | e-mail: buskulic@lapp.in2p3.fr  | FRANCE                          |
> =====================================================================
> mailto:buskulic@lapp.in2p3.fr
> 



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:39 MET