RE:makefiles with root: a question

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Wed Feb 23 2000 - 10:36:27 MET


I send you this email because I can't get through with compiling cint programs
. May be you can help me.  In this case, I would be very grateful to you.

I use the pro version of root, on Linux redhat 6.

I always received those kind of error messages
>make
g++ -o corsaires corsaires.cc -I/cern/root/include -O -Wall -fPIC  
-I/cern/root/include -L/cern/root/lib -lNew -lCore -lCint -lHist -lGraf 
-lGraf3d 
-lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lm -ldl -rdynamic 
corsairesObjC.o  
/tmp/ccAonME3.o: In function `main':
/tmp/ccAonME3.o(.text+0x254): undefined reference to `TFile::TFile(char const 
*, 
char const *, char const *, int)'
collect2: ld returned 1 exit status
make: *** [corsaires] Error 1
linstar5>

when I try to compile my cint program corsdaires.cc, with classes defined in 
corsairesObj.h

I send you corsaires.cc, corsairesObj.h (I simplfied them as much as possible 
for this mail),  my LinkDef.h and my Makefile:

-------------------------Corsaires.cc--------
#include "corsairesObj.h"

ClassImp(Part)
ClassImp(ShowerHeader)
ClassImp(Event) 

TROOT root(" "," ");


int main()
{
TFile *EvTFile=new TFile("a root file","RECREATE","a root file");
EvTFile->Close();
return 0;
}

----------------------------------------------
-------------corsairesObj.h-------------------
#ifndef RUNOBJ_H
#define RUNOBJ_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>
#include <iostream.h>
#include "/cern/root/include/TFile.h"
#include "/cern/root/include/TTree.h"
#include "/cern/root/include/TROOT.h"
#include "/cern/root/include/TObject.h"



class Part:public TObject
{
private:
public:

Part(){};

~Part(){};
ClassDef(Part,1)
};


class ShowerHeader:public TObject
{
private:
public:

ShowerHeader(){};
~ShowerHeader(){};

ClassDef(ShowerHeader,1)
};

class Event:public TObject
{
private:
public:

~Event(){};
ClassDef(Event,1)
};

#endif
---------------------------------------------

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


ROOTSYS=/cern/root
# Linux with egcs
CXX           = g++
CXXFLAGS      =-I$(ROOTSYS)/include -O -Wall -fPIC 
LD            = g++
LDFLAGS       = -g
SOFLAGS       = -shared


CXXFLAGS     += $(ROOTCFLAGS)
LIBS          = $(ROOTLIBS)
GLIBS         = $(ROOTGLIBS)


all: corsaires
clean:
        rm *.o *C.*  

corsairesObjC.cc: corsairesObj.h LinkDef.h
        $(ROOTSYS)/bin/rootcint -f corsairesObjC.cc -c corsairesObj.h LinkDef.
h  
corsairesObjC.o: corsairesObjC.cc 
        $(CXX) -c corsairesObjC.cc $(CXXFLAGS) 

corsaires: corsaires.cc corsairesObjC.o
        $(CXX) -o corsaires corsaires.cc $(CXXFLAGS) $(LIBS) corsairesObjC.o  

----------------------------------------------


-------------------Linkdef,h------------------
#ifdef __CINT__

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;


#pragma link C++ class Part;
#pragma link C++ class ShowerHeader;
#pragma link C++ class Event;


#endif
----------------------------------------------

I type "make" in the directory in which all those files belong, and 
/cern/root/include is the right pass in my computer for the .h files
Hello Rooters,

I get following question.  This is about building ROOT application.
My speciality is limited on pure Cint, so would anybody answer his 
question?

Thank you
Masaharu Goto

==============================================================================

So my question is: Can you see what's missing in any of my files that explain 
for the error messages?

When I copy /root/test into a directory "test", and type "make" inside to 
compile Event.cxx, I also get an error:
make
g++ -O -Wall -fPIC -I/cern/root/include -c Event.cxx
g++ -O -Wall -fPIC -I/cern/root/include -c EventDict.cxx
g++ -O -Wall -fPIC -I/cern/root/include -c MainEvent.cxx
g++ -shared -g Event.o EventDict.o -o libEvent.so
g++ -g MainEvent.o Event.o EventDict.o -L/cern/root/lib -lNew -lCore -lCint 
-lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -l
m -ldl -rdynamic -o Event
MainEvent.o: In function `main':
MainEvent.o(.text+0x746): undefined reference to `TFile::TFile(char const *, 
char const *, char const *, int)'
MainEvent.o(.text+0xa15): undefined reference to `TFile::TFile(char const *, 
char const *, char const *, int)'
MainEvent.o(.text+0xb3e): undefined reference to `TDirectory::TDirectory(char 
const *, char const *, char const *)'
collect2: ld returned 1 exit status
make: *** [Event] Error 1

so probably it's an installation problem, but I can't see which.

With my best regards,
Gilles Zalamansky
University of leeds, UK



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