[ROOT] Linking Problem caused by TFile on Linux

From: Christian Haeberli (christian.haeberli@cern.ch)
Date: Thu Sep 28 2000 - 11:47:58 MEST


Hello

I have got a problem compiling a program with the TFile class on Linux.
TFiles causes a linking problem. 

The error Message is:
--
g++ -w -I/cern/root/include -c striperoot.cc -DVERS_1 -o striperoot.o
g++ -g striperoot.o -L/cern/root/lib -lNew -lCore -lCint -lHist -lGraf
-lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics  -L/lib
-ldl -lm -o striperoot
striperoot.o: In function `main':
striperoot.o(.text+0x84): undefined reference to `TFile::TFile(char
const *, char const *, char const *, int)'
collect2: ld returned 1 exit status
make: *** [striperoot] Error 1  
--


The source and the makefile is attached to this message.

Do I have to link something more? Any ideas?

Thank you

Christian


-- 
___________________________________________________________________
Christian Haeberli                       christian.haeberli@cern.ch
University of Bern
Laboratory for High Energy Physics       Phone : ++ 41 31 631 4069
Sidlerstr. 5                             Mobile: ++ 41 76 316 6159
CH-3012 BERN                             Fax   : ++ 41 31 631 4487


#include<iostream.h>

#include "TROOT.h"
#include "TRint.h"
#include "TFile.h"
#include "TNtuple.h"
#include "TCanvas.h"
#include "TVirtualPad.h"
#include "TApplication.h"
#include "TH1.h"
#include "TSystem.h"

extern void InitGui();  // loads the device dependent graphics system
VoidFuncPtr_t initfuncs[] = { InitGui, 0 };
int Error;              // needed by Motif

TROOT striperoot("striperoot","DAQ",initfuncs);

void main ()
    
{
    Int_t nlines = 0;
    Int_t ncols;
    int event[4];
    float eventfloat[4];
    char line[50];
    int i;

    FILE *fp = fopen("/home/duck/sbs_test/markus1.dat","r");
    float *x;
    cout<<"Hello World"<<endl;
    
    TFile *file = new TFile("markus1.root","RECREATE","Hodoskop Strip Test");
    TApplication *theApp = new TApplication("theApp", 0, NULL);
    TNtuple *ntuple = new TNtuple("ntuple","data from ascii file","eventnr:adcch0:adcch1:flag",100000);
    TCanvas *c1 = new TCanvas("c1","hello",200,10,700,500); 
    TH1F *hprof = new TH1F("hprof","Pulse Height Distribution",30,30.5,59.5);


    hprof->Draw();

    while (fgets(line,50,fp)) {
	if (line[0]=='a') {
	    sscanf(line,"a %x %d %d %d",&event[0],&event[1],&event[2],&event[3]);
	    printf("%x\t%d\t%d\t%d\n",event[0],event[1],event[2],event[3]);
	    for (i=0;i<4;i++) {
		eventfloat[i]=(float)event[i];
	    }
	    ntuple->Fill(eventfloat);
	}
    }                                                             

    file->Append(ntuple);

    ntuple->Show(20);
    ntuple->Draw("adcch1>>hprof");
    hprof->Fit("gaus");

    theApp->Run();
    
    delete theApp;
    
}























#cdir = /big/opt/WorkShop/SUNWspro

CC = g++

#ROOTSYS       = /big/cern/root

ROOTLIBS      = -L$(ROOTSYS)/lib -lNew -lCore -lCint -lHist -lGraf \
                -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix \
                -lPhysics 


LIBS          = $(ROOTLIBS) -L/lib -ldl -lm

INCLUDE       = -I$(ROOTSYS)/include



helloroot: helloroot.o
	$(CC) -g helloroot.o $(LIBS) -o $@

helloroot.o: helloroot.cc makefile
	$(CC) -w $(INCLUDE) -c helloroot.cc -DVERS_1 -o $@

testcanvas: testcanvas.o
	$(CC) -g testcanvas.o $(LIBS) -o $@

testcanvas.o: testcanvas.cc makefile
	$(CC) -w $(INCLUDE) -c testcanvas.cc -DVERS_1 -o $@

striperoot: striperoot.o
	$(CC) -g striperoot.o $(LIBS) -o $@

striperoot.o: striperoot.cc makefile
	$(CC) -w $(INCLUDE) -c striperoot.cc -DVERS_1 -o $@



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:34 MET