Problems compiling library for interactive use

Hi All,

I’m experiencing trouble compiling a library so that I can load it in root and run it from a macro. The base package I’m using worked fine previously, but I recently tried adding a class generated by TMVA to apply multivariate cuts. The package compiles fine, but when I try to load it in root, I get the error:

dlopen error:
/afs/slac.stanford.edu/u/br/tomo/ana41/workdir/./…/shlib/Linux24SL3_i386_gcc323/libRhoPiProduction.so:
undefined symbol: _ZTV21ReadRuleFitTauPrec001 Load Error: Failed to load
Dynamic link library
/afs/slac.stanford.edu/u/br/tomo/ana41/workdir/./…/shlib/Linux24SL3_i386_gcc323/libRhoPiProduction.so

where ReadRuleFitTauPrec001 is the name of the class generated by TMVA. The file generated by TMVA contained a virtual class
( IClassifierReader) and a class (ReadRuleFitTauPrec001) which inherited
from the virtual class. Following example code I’ve seen, I created two
rdl files to contain the class definitions and one cc file for the
method declarations of ReadRuleFitTauPrec001 (all the method definitions
for IClassifierReader were contained in the main class block so it
wasn’t necessary to make a separate .cc file). At the end of the
IClassifierReader class definition block, I inserted
"ClassDefT(IClassifierReader,1)" and at the end of the
ReadRuleFitTauPrec001 class definition block, I inserted
"ClassDefT(ReadRuleFitTauPrec001,1)". Also, at the beginning of the
ReadRuleFitTauPrec001.cc file, I added

#include "ReadRuleFitTauPrec001.hh"
ClassImp(ReadRuleFitTauPrec001)

Both rdl files have ifndef blocks to prevent redefinition. Finally, in
the package’s LinkDef file, I added:

#pragma link C++ class IClassifierReader;
#pragma link C++ class ReadRuleFitTauPrec001;

Am I missing a step here? Can anyone suggest why the package compiles
without any errors, but loading the library indicates that
ReadRuleFitTauPrec001 is undefined?

Thanks,

Tomo

undefined symbol: _ZTV21ReadRuleFitTauPrec001 Load Error: Failed to loadThis means that the virtual table for ReadRuleFitTauPrec001 has not been generated. This is usually because the ‘first’ virtual function has not be implemented.

[quote]At the end of the
IClassifierReader class definition block, I inserted
"ClassDefT(IClassifierReader,1)" [/quote]Unless you have a class template you should not use ClassDefT but ClassDef.

In the LinkDef I recommend that you request the new I/O by prefixing a + to the class names:#pragma link C++ class IClassifierReader+; #pragma link C++ class ReadRuleFitTauPrec001+;

Cheers,
Philippe

Hi Philippe,

Thanks for the reply. I made those changes, but I’m still getting the same error. Any other suggestions? Is there some way I can try to get more information on the source of the problem?

Thanks,

Tomo

[quote]Code:
undefined symbol: _ZTV21ReadRuleFitTauPrec001 Load Error: Failed to load
This means that the virtual table for ReadRuleFitTauPrec001 has not been generated. This is usually because the ‘first’ virtual function has not be implemented. [/quote]This you make sure that you implemented all functions in the class? If you did, did you make sure that you linked in the compiled dictionary (i.e. the result of rootcint)?

Cheers,
Philippe


Hi,

Yes, all the functions are implemented. As for linking in the "result of rootcint", I'm a bit unclear on what you mean. I haven't really had to deal with compiling libraries for interactive use in the past and am just trying to copy the approach I see used in other people's code. I included the pragma link line with a + sign as you suggested and I try to load the compiled library (RhoPiProduction which includes the ReadRuleFitTauPrec001 and IClassifierReader classes) but it still gives the same error...

-Tomo

Hi,

Yes, all the functions are implemented. As for linking in the “result of rootcint”, I’m a bit unclear on what you mean. I haven’t really had to deal with compiling libraries for interactive use in the past and am just trying to copy the approach I see used in other people’s code. I included the pragma link line with a + sign as you suggested and I try to load the compiled library (RhoPiProduction which includes the ReadRuleFitTauPrec001 and IClassifierReader classes) but it still gives the same error…

-Tomo

Hi Tomo,

Could you remind how you create the library. I am a little fuzy on what you have and how you are compiling it. What is your actual list of file (header, source, linkdef.h, etc.) and what is/are the command line(s) that you issue to create the library?

Cheers,
Philippe.

PS. Or better yet, attach a complete running example.

Hi Philippe,

I’ve put a tgz of the current state of the package at slac.stanford.edu/~tomo/RhoP … A_Jul1.tgz

The file TMVAnalysis_All__RuleFitTauPrec001.class.C (which isn’t part of the package but is included in the tarball) is a copy of the class generated by TMVA. The RhoPiProduction package was written by others and the version in the tgz contains a number of my additions and changes including the ReadRuleFitTauPrec001.[rdl/cc] and IClassifierReader.rdl classes. The ReadRuleFitTauPrec001 class is actually used in DDNtuple.cc and DDAlgV3.cc. There are also TMVA_Reader files are left over from a previous version. I compile using gmake RhoPiProduction.rootlib ROPT=-Shared. The makefile is included. I appreciate the help.

Thanks,

Tomo

Simply apply the following patch:[code]diff GNUmakefile.standalone.orig GNUmakefile.standalone
112c112
< @cd (INCDIR) ; (ROOTSYS)/bin/rootcint -f (CINTFILE) -c (INCLUDES) $(HHLIST)

@cd (INCDIR) ; (ROOTSYS)/bin/rootcint -f (CINTFILE) -c (INCLUDES) (HHLIST) (PACKAGE)_LinkDef.hh
[/code].i.e actually pass the LinkDef to rootcint (otherwise the dictionary for most of your classes is not created).

Cheers,
Philippe

Hi Philippe,

Unfortunately, I’m still getting the same error after editing the makefile. Any other ideas?

Thanks,

Tomo

Hi,

I was not able to run the compilation of code to completion (missing header files from dependent product like CLHEP). If you send a standalone example, I will try to look into it further.

Cheers,
Philippe.

PS. The issue is still most likely that the dictionary for the class ReadRuleFitTauPrec001 is not produced and/or not linked into your shared library and/or executable (check your linkdef file, check you gmake output to make sure rootcint is run with the linkdef as a parameter and that the dictionary is compiled and linked in)>