TSpectrum error on the version installed on my laptop

Hello,

I just installed ROOT on my laptop ( I have Ubuntu Fiesty Fawn 7.04) a few days ago ( I downloaded it using cvs )
I had a few problems during the installation ( I had a bunch of missing libraries on my laptop) but I managed to make it work.

So I tried to compile and run some programs and everything seemed to be fine but…

the following command ( that was just fine when I used it on the computers at work ) is not going through the compilations anymore :

TSpectrum *s1 = new TSpectrum(1);
( I also tried to change it to : TSpectrum *s1 = new TSpectrum(1,0.1);

error message :

/home/zelrikriando/G0Work/macro/ARS/ARSSUMMethod.h:313: undefined reference to `TSpectrum::TSpectrum(int, float)'
collect2: ld a retourné 1 code d’état d’exécution
make: *** [ARSSUMMethod] Erreur 1

I am lost because the same program compiles the desktop computers at work and not on my laptop… :confused:

Is this a problem with my install ? or a library issue?


Note : TSpectrum *s1 = new TSpectrum(1); doesnt produce any error on my laptop if I just run ROOT and type it :

root [0] TSpectrum *s2 = new TSpectrum(1);
root [1]


Help me please :frowning:

Could you identify your version of ROOT and provide a short RUNNING script reproducing your problem?

Rene

My ROOT version is : 5.15/07

Ok so I tried to make a test program and I notice that I can reproduce the problem only if I use the Makefile to compile it :

//MainTest.C
#include <stdio.h>
#include
#include <TROOT.h>
#include <TApplication.h>
#include <TSpectrum.h>

using namespace std;

int main(int argc, char *argv[]){

TApplication theApp(“App”,&argc,argv);

TSpectrum *s1 = new TSpectrum(1);

cout << "test done " << endl;

theApp.Run();
}

Makefile

ROOTCFLAGS = $(shell root-config --cflags)
ROOTLIBS = $(shell root-config --libs) -lNew
ROOTGLIBS = $(shell root-config --glibs)

CXX = g++
CXXFLAGS = -g -O2 -Wall -fPIC -DEXE
CXXFLAGS += $(ROOTCFLAGS)
OPTIM= -O2 -fexpensive-optimizations -funroll-loops
LIBS = $(ROOTLIBS)
GLIBS = $(ROOTGLIBS)

MainTest: MainTest.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $@.o $(LIBS) $(GLIBS)

clean:
@rm -f *.o core

and when I try to make :

$ make MainTest
g++ -g -O2 -Wall -fPIC -DEXE -pthread -I/home/zelrikriando/G0Work/ROOT/root/include -c -o MainTest.o MainTest.C
MainTest.C: In function ‘int main(int, char**)’:
MainTest.C:20: attention : unused variable ‘s1’
g++ -g -O2 -Wall -fPIC -DEXE -pthread -I/home/zelrikriando/G0Work/ROOT/root/include -o MainTest MainTest.o -L/home/zelrikriando/G0Work/ROOT/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -pthread -lm -ldl -rdynamic -lNew -L/home/zelrikriando/G0Work/ROOT/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lGui -pthread -lm -ldl -rdynamic
MainTest.o: In function main': /home/zelrikriando/G0Work/macro/ARS/test/MainTest.C:20: undefined reference toTSpectrum::TSpectrum(int, float)'
collect2: ld a retourné 1 code d’état d’exécution
make: *** [MainTest] Erreur 1

…Hope this helps :S

You must link with -lSpectrum

Rene

It works !

Thanks Rene :smiley:

Hi!

sorry, but what does “link with” mean in that context? How do I do that?

Thank you very much!

Rene was talking about a compiler switch, -l, used to specify the library to link your binaries with.

Danilo