Problem with ACLiC and shared libraries

Dear Rooters

Yesterday I downloaded the newest CVS version to solve the initial
problems with ACLiC. Sorrowly, this does not solve my real problems,
namely compiling a macro which loads my own libraries.

Compiling the simple macro “macroExpress.C” results in a lot of
warnings (shown below) but is able to run.
However, a more complex macro, which uses many of my own classes,
does not only display many more warnings but also the following
error message:
dlopen error: dlcompat: dyld: /Users/cs/ROOT/root/bin/root.exe Undefined symbols:
__ZN10XAlgorithm14InitParametersEiPd
_ZN11XHybridizer10InitArraysEiPdS0_S0_PiS0_S0_S0_S1
__ZN11XHybridizer11DeleteArrayEv
_ZN14XProbeSelectorC1EPKcS1
__ZN15XArithmeticMeanC
Load Error: Failed to load Dynamic link library /Users/cs/ROOT/rootcode/xpsx/./macroExpress1_C.so

My questions are:
How can I avoid the many warning messages?
What causes the error message?

Best regards
Christian

//---------begin macroExpress.C-----------
#include “TFile.h”
#include “TTree.h”
#include “TString.h”
#include “TSystem.h”

#ifndef CINT
#include <Riostream.h>

#include “XPSUtils.h”
#include “XPSBase.h”
#endif

void Init()
{
gSystem->Load(“libXPSUtils.so”);
gSystem->Load(“libXPSBase.so”);
}//Init

Int_t Preprocess()
{
TFile *fFile = new TFile(“Test3_cel.root”,“READ”);
fFile->cd();
XContent fData = (XContent)(fFile->Get(“Content”));
cout << “Content <” << fData->GetName() << “>” << endl;
return 0;
}//Preprocess
//---------end macroExpress.C-----------

root [0] .L macroExpress.C+
Info in TUnixSystem::ACLiC: creating shared library /Users/cs/ROOT/rootcode/xpsx/./macroExpress_C.so
In file included from /Users/cs/ROOT/rootcode/xpsx/macroExpress.C:25,
from /Users/cs/ROOT/rootcode/xpsx/tmp_0_NefQtR.h:32,
from /Users/cs/ROOT/rootcode/xpsx/tmp_0_NefQtR.cxx:13:
/Users/cs/ROOT/root/include/TObject.h:114: warning: virtual void TObject::Draw(const Option_t*)' was hidden /Users/cs/ROOT/rootcode/xpsx/XPSUtils.h:178: warning: byvirtual Int_t
XPlot::Draw(const char*, const char*, const char*, const char*, const char*,
const char*, const char*, const Option_t*, double, double, double, double,
double, double, int, bool)’
/Users/cs/ROOT/root/include/TNamed.h:60: warning: virtual void TNamed::SetTitle(const char*)' was hidden /Users/cs/ROOT/rootcode/xpsx/XPSUtils.h:222: warning: byvoid
XPlot::SetTitle(const char*, int)‘
In file included from /Users/cs/ROOT/rootcode/xpsx/macroExpress.C:26,
from /Users/cs/ROOT/rootcode/xpsx/tmp_0_NefQtR.h:32,
from /Users/cs/ROOT/rootcode/xpsx/tmp_0_NefQtR.cxx:13:
/Users/cs/ROOT/root/include/TList.h:64: warning: virtual TObject* TList::FindObject(const TObject*) const' was hidden /Users/cs/ROOT/rootcode/xpsx/XPSBase.h:98: warning: byvirtual
TObject* XContent::FindObject(const char*, bool) const’
/Users/cs/ROOT/root/include/TList.h:63: warning: virtual TObject* TList::FindObject(const char*) const' was hidden /Users/cs/ROOT/rootcode/xpsx/XPSBase.h:98: warning: byvirtual
TObject* XContent::FindObject(const char*, bool) const’
/Users/cs/ROOT/root/include/TObject.h:114: warning: virtual void TObject::Draw(const Option_t*)' was hidden /Users/cs/ROOT/rootcode/xpsx/XPSBase.h:402: warning: byvirtual Int_t
XManager::Draw(const char*, const char*, const char*, const char*, const
char*, const char*, const char*, const Option_t*, double, double, double,
double, double, double, int, bool)'
root [1] Init()
root [2] Preprocess()
Content
(Int_t)0
root [3]

[quote]/Users/cs/ROOT/root/include/TObject.h:114: warning: virtual void TObject::Draw(const Option_t*)' was hidden /Users/cs/ROOT/rootcode/xpsx/XPSUtils.h:178: warning: byvirtual Int_t
XPlot::Draw(const char*, const char*, const char*, const char*, const char*,
const char*, const char*, const Option_t*, double, double, double, double,
double, double, int, bool)’ [/quote]
As indicated, your method XPlot::Draw is hidding TObject’s Draw method (from the C++ point of view). To solver the issue, you need to add the line

using TObject::Draw; using TNamed::SetTitle; etc....within yoru class declarations.

However, you also need to make sure you did not intend to “overload” those method (in which case you need the same argument list).

[quote]dlopen error: dlcompat: dyld: /Users/cs/ROOT/root/bin/root.exe Undefined symbols:
__ZN10XAlgorithm14InitParametersEiPd
_ZN11XHybridizer10InitArraysEiPdS0_S0_PiS0_S0_S0_S1
__ZN11XHybridizer11DeleteArrayEv
_ZN14XProbeSelectorC1EPKcS1
__ZN15XArithmeticMeanC
Load Error: Failed to load Dynamic link library /Users/cs/ROOT/rootcode/xpsx/./macroExpress1_C.so[/quote]

You probably either forgot to implement those methods/functions or you have not loaded the corresponding library.

Cheers,
Philippe.

Dear Philippe

Your answer results in some confusion:
Does ROOT now use namespaces?
Are all compilers supporting namespaces and the word “using”?

ad 1) Consider the following class:

[code]class XContent: public TList {
protected:
TString fTitle;

public :
XContent();
XContent(const char *name, const char *title = “”, const char *type = “”);
virtual ~XContent();

  virtual TObject  *FindObject(const char *name, Bool_t ignoreCase = kFALSE) const;

  void SetTitle(const char *title)     {fTitle = title;}
  virtual const char *GetTitle() const {return fTitle.Data();}

  ClassDef(XContent,1) //Content

};[/code]

Where do I have to put the word “using”?
(I am not very familiar with namespaces and think that they only
complicate things.)

ad 2) I do not understand the error, since all my libraries are tested and
work in my usual macros and my standalone application. I also did not
forget to load the corresponding libraries.
Consider e.g. XAlgorithm, which is mentioned in the error. This class
is defined in my libray libXPSBase.so, which I have loaded even in the
simple macro macroExpress.C. Why do I not get the error in this macro?

Best regards
Christian

Hi Christian,

“using TObject::Draw;”

is fairly new C++ syntax to easily overload methods in a derived class. It has nothing to do with namespaces (but it allows basically the usage of methods from a base class “namespace” so using “using” is appropriate :wink:).

In the past you would write:

void XContent::Draw(Option_t *opt) { TObject::Draw(opt); }

Cheers, Fons.

Dear Fons

Thank you for this explanation, now I understand it.
Finally, C++ has added a feature, which Apple´s ObjectPascal had
from the beginning. There you could write:

procedure XContent.Draw(opt: Option_t) begin inherited Draw(opt); end
I have always missed this feature.
I hope that all compilers which ROOT supports, do understand it.

Best regards
Christian