Root dosen't like my Undefined Constructor

I had a working root code simAnal_cxx and added a new module to it and now it complies but gives the complaint afterwards.

dlopen error: /home/osenbaug/MaGe/analysis/simAnal_cxx.so: undefined symbol: _ZN11ClusterDataC1Ev
Load Error: Failed to load Dynamic link library /home/osenbaug/MaGe/analysis/simAnal_cxx.so

An nm check on the object file finds that indeed,_ZN11ClusterDataC1, which is the symbol associated with the constructer for my new class is undefined, see

nm simAnal_cxx.so|grep Cluster
U _ZN11ClusterData10InitializeEv
U _ZN11ClusterData7SetSeedEffff
00002550 W _ZN11ClusterData8GetSeedXEv
000059c2 t _ZN11ClusterData8GetSeedXEv.A
0000a22c d _ZN11ClusterData8GetSeedXEv.A$$LSDA
000059b8 t _ZN11ClusterData8GetSeedXEv.J
0000a228 d _ZN11ClusterData8GetSeedXEv.J$$LSDA
00002598 W _ZN11ClusterData8GetSeedYEv
000059fa t _ZN11ClusterData8GetSeedYEv.A
0000a234 d _ZN11ClusterData8GetSeedYEv.A$$LSDA
000059f0 t _ZN11ClusterData8GetSeedYEv.J
0000a230 d _ZN11ClusterData8GetSeedYEv.J$$LSDA
000025e0 W _ZN11ClusterData8GetSeedZEv
00005a32 t _ZN11ClusterData8GetSeedZEv.A
0000a23c d _ZN11ClusterData8GetSeedZEv.A$$LSDA
00005a28 t _ZN11ClusterData8GetSeedZEv.J
0000a238 d _ZN11ClusterData8GetSeedZEv.J$$LSDA
U _ZN11ClusterData9SetMemberEffffi
U _ZN11ClusterDataC1Ev
U _ZN11ClusterDataD1Ev

However, it is my understanding that it is supposed to be undefined, because it is defined in the external file ClusterData.cc. An nm check on the other constructors in .hh files shows that they too are undefined, but this causes no problems. I am at a loss.

Here are the files I added to the working file;

// --------------------------------------------------------------------------//
/**

  • TITLE: ClusterData.hh
  • AUTHOR: E. Osenbaugh-Stewart
    */
    // --------------------------------------------------------------------------//

#ifndef _ClusterData_hh
#define _ClusterData_hh

#include “TTree.h”
#include “TObject.h”

class ClusterData : public TObject
{

public:
//Functions
ClusterData();
~ClusterData();
Int_t Initialize();
Int_t GetSeedX(){return SeedX;}
Int_t GetSeedY(){return SeedY;}
Int_t GetSeedZ(){return SeedZ;}
void SetSeed(Float_t x,Float_t y,Float_t z,Float_t E);
void SetMember(Float_t x,Float_t y,Float_t z,Float_t E, Int_t pos);
//Objects
Int_t ClusterSize;

private:
//Seed Coordinates
Float_t SeedX;
Float_t SeedY;
Float_t SeedZ;
Float_t SeedEnergyDep;
//Member Coordinates
Float_t InteractionX[30];
Float_t InteractionY[30];
Float_t InteractionZ[30];
//Energy Info
Float_t EnergyDep[30];

ClassDef(ClusterData, 1)

};
#endif

/**

  • TITLE: ClusterData.cc
  • AUTHOR: E. Osenbaugh-Stewart
    */
    //---------------------------------------------------------------------------//
    //

#include “ClusterData.hh”
#include
#include “io/MGLogger.hh”
#include “TObject.h”

//--------------------------------------------------------------------------//
ClassImp(ClusterData)

ClusterData::ClusterData() :
SeedX(0),
SeedY(0),
SeedZ(0),
{;}

//---------------------------------------------------------------------------//

ClusterData::~ClusterData()
{;}

//---------------------------------------------------------------------------//

ClusterData::Initialize(){

Int_t a;

SeedEnergyDep = 0;
ClusterSize = 0;
for (a=0; a<30; a++){
InteractionX[a] = 0;
InteractionY[a] = 0;
InteractionZ[a] = 0;
EnergyDep[a] = 0;
}
return (1);
}

//---------------------------------------------------------------------------//

ClusterData::SetSeed(Float_t z, Float_t y, Float_t z, Float_t E){

SeedX = x;
SeedY = y;
SeedZ = z;
SeedEnergyDep = E;

}

//---------------------------------------------------------------------------//

/*ClusterData::GetSeed(){

}*/

//---------------------------------------------------------------------------//

ClusterData::SetMember(Float_t z, Float_t y, Float_t z, Float_t E, Int_t pos){

InteractionX[pos] = x;
InteractionY[pos] = y;
InteractionZ[pos] = z;
EnergyDep[pos] = E;

}
I added the include line #include “ClusterData.hh” simAnalcxx is attached if that helps.

Thanks for your help,

Eliza
simAnal.cxx (18.9 KB)

Hi,
looks like you are not linking with the libClusterData.so or whatever name the library has that contains the compiled version of ClusterData.cc. You might need to compile and load that first. Or you can generate a wrapper script, that #includes both ClusterData.cc and simAnal.cxx
Cheers, Axel.

Okay, I took your advice and complied ClusterData into a library first (libROOT_clusterdata.so) but when I try to load in that library it won’t let me. It says

root [1] .L /home/osenbaug/MaGe/analysis/libROOT_ioROOT.so
root [2] .L /home/osenbaug/MaGe/analysis/libROOT_mjioROOT.so
root [3] .L /home/osenbaug/MaGe/analysis/libROOT_clusterdata.so
dlopen error: /home/osenbaug/MaGe/analysis/libROOT_clusterdata.so: cannot dynamically load executable
Load Error: Failed to load Dynamic link library /home/osenbaug/MaGe/analysis/libROOT_clusterdata.so
*** Interpreter error recovered ***

I attached the object file if that helps. Also could you explain the wrapper tech you mentioned?

Thanks Again,

Eliza

Hi,

how exactly do you build the libraries? Does libROOT_clusterdata.so have a main() function? (It cannot - it’s a library, not an executable.)

You can create a libraries.C that has the lines
#includeClusterData.cc
#include “AllTheOtherSourcesYouBuildLibsFrom.cxx”
#include "simAnal.cxx "
and then just run “.L libraries.C+” and you will create and load a library containing all the sources.

Cheers, Axel.