ACLiC issue: 'undefined reference to' methods from own class

Hi,

I’ve developed a code responsible for reconstruction of tracks for my physics analysis. However, when I’m invoking methods implemented in classes, during the ACLiC linking such an error occurs:

StPP2PPReconstruction_cxx_ACLiC_dict.cxx:(.text+0x20c2): undefined reference to `StPP2PPElasticEvent::setTrack(int const&, StPP2PPTrack*)' StPP2PPReconstruction_cxx_ACLiC_dict.cxx:(.text+0x20cf): undefined reference to `StPP2PPElasticEvent::getTrack(int const&) const' collect2: ld returned 1 exit status Error in <ACLiC>: Compilation failed!

The piece of code responsible for this error:

StPP2PPElasticEvent* a = new StPP2PPElasticEvent(); StPP2PPTrack* b = new StPP2PPTrack(); Int_t index = 0; a->setTrack(index, b); a->getTrack(index);

I will be very grateful for any help. I’m also attaching files with class StPP2PPElasticEvent;

Best regards,
Rafal

StPP2PPElasticEvent.h (647 Bytes)
StPP2PPElasticEvent.cxx (937 Bytes)

You don’t say how you invoke ACLiC, but I suspect you try to make it compile the header. Since your header only contains the declarations, not the definitions this fails. What you really want to do is compile the source file (and make sure to include the header there which you did).

root [0] .L StPP2PPElasticEvent.cxx+

http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix gives some more explanation as to what kind of mistakes trigger this problem in general.

Actually, I’m invoking ACLiC in the following starting macro:

[code]void analysis_start(TString run) {

gROOT->ProcessLine(".L st_track.cxx+");
gROOT->ProcessLine(".L StMuRpsCollection.cxx+");
gROOT->ProcessLine(".L StBbcTriggerDetector.cxx+");
gROOT->ProcessLine(".L StZdcTriggerDetector.cxx+");
gROOT->ProcessLine(".L particle_event.cxx+");
gROOT->ProcessLine(".L StPP2PPHit.cxx+");
gROOT->ProcessLine(".L StPP2PPTrack.cxx+");
gROOT->ProcessLine(".L StPP2PPElasticEvent.cxx+");
gROOT->ProcessLine(".L StPP2PPReconstruction.cxx+");

TChain chaindt(“PicoTree”);
chaindt.Add("/DATA/run+".el.root");
chaindt.Process(“analysis.C+”,run);
}[/code]

So I probably do it in the right way…

I’m sorry for confusion, the solution is rather simple. Inline functions should be defined in header file, that was the issue.

Regards,
Rafal