Undefined reference to TSpectrum

Hello everyone,

I tried to use TSpectrum in my code to find peaks in Histograms and wanted to get expose the background.

The problem I experience is that I get error messages of type:

/tmp/cc8t1vYP.o: In function main': Spectrum.cc:(.text+0x3312): undefined reference toTSpectrum::TSpectrum(int, float)'
collect2: ld returned 1 exit status

My code is simply:

TSpectrum *see = new TSpectrum(2 , 1.7);
Int_t nfound = see->Search( LonePixHist1 , 2 , " " , 50);

I have of course included TSpectrum like :

#include “TSpectrum.h”

and have also tried

#include <TSpectrum.h> .

Does anyone know, what I am doing wrong?

The root version I am using is 5.20.

Thanks in advance,


looks like you did not link with libSpectrum


Hello to all,
me too have the same problem. Which is the protocol to link with libSpectrum?

Usually I compile my program with:
g++ -o file file.cpp root--config --cflags --glibs

and the output is:
undefined reference to TSpectrum::TSpectrum(int, float)'
collect2: ld returned 1 exit status

Thank you in advance

Add “-lSpectrum” in the end of your g++ command line.

Perfect, thank you very much!