Makefile problem

Hi Experts

Could you please help me about the Makefile
Sorry for this dump question but I really have no idea for Makefile.
And I guess the problem must be from my Makefile.

I tried to get my class compiled but i still keep getting the error message which complaining about TFile TH1D not defined in current scope ( those TObjests but I do include TObject.h )

ps1. Basically, I followed Ch15 of user guide and it can be run by ACLiC
ps2. my system is ubuntu 8.10

Thank you very much!
SC

This is my Makefile
#---------------------------------------------------
CXX = g++
CXXFLAGS = -O -Wall -fPIC -shared
LD = g++
LDFLAGS = -g
SOFLAGS = -shared

ROOTCONFIG := root-config

ROOTCFLAGS := $(shell $(ROOTCONFIG) --cflags)
ROOTLIBS := $(shell $(ROOTCONFIG) --libs)

LIBS += $(ROOTLIBS) -lMinuit
CXXFLAGS += $(ROOTCFLAGS) -Iinclude

HDRS = MassTemplate.h

SRCS = MassTemplate.cc

LIB = masstmplib.so

all: $(LIB)

$(LIB): $(OBJS) masstmplibdict.cc
@echo “Linking $(LIB) …”
@/bin/rm -f $(LIB)
@$(LD) $(CXXFLAB) $(LIB) -o $@ $^
@echo “done”

clean:; @rm -f $(LIB) masstmplibdict.cxx masstmplibdict.h core

masstmplibdict.cc: $(HDRS) LinkDef.h
@rm -f $@
@echo "Generating dictionary: " $@
@echo " from: " $^
${ROOTSYS}/bin/rootcint $@ -c $^
#---------------------------------------------------

[quote]I tried to get my class compiled but i still keep getting the error message which complaining about TFile TH1D not defined in current scope ( those TObjests but I do include TObject.h )
[/quote]
You need to include TH1D.h

Cheers,
Philippe.

Hi Philippe

I’ve tried that …it still throw out the same error message(not only TH1D…all TObjects it doesn’t like …) and that’s why I guess I didn’t get the Makefile right.

Besides, I also tried that setting my codes in root/ or root/mypackage but it doesn’t work …

Cheers,
SC

[quote=“pcanal”][quote]I tried to get my class compiled but i still keep getting the error message which complaining about TFile TH1D not defined in current scope ( those TObjests but I do include TObject.h )
[/quote]
You need to include TH1D.h

Cheers,
Philippe.[/quote]

Hi,

What is the compile line issued by your makefile when compiling your source file? What is the exact first error message you see?

Philippe

Hi Philippe

Below are the error message I got …

Thanks,
SC

========error message===========
sckao@sck:~/root/MyAnalysis$ make
Generating dictionary: masstmplibdict.cc
from: MassTemplate.h LinkDef.h
/home/sckao/root/bin/rootcint masstmplibdict.cc -c MassTemplate.h LinkDef.h
Linking masstmplib.so
g++: masstmplib.so: No such file or directory
masstmplibdict.cc:7:37: error: RConfig.h: No such file or directory
In file included from masstmplibdict.cc:16:
masstmplibdict.h:18:24: error: cint/G__ci.h: No such file or directory
masstmplibdict.h:31:21: error: TObject.h: No such file or directory
masstmplibdict.h:32:30: error: TMemberInspector.h: No such file or directory
In file included from masstmplibdict.h:33,
from masstmplibdict.cc:16:
MassTemplate.h:5:18: error: TH1D.h: No such file or directory
MassTemplate.h:6:18: error: TH2D.h: No such file or directory
MassTemplate.h:7:21: error: TCanvas.h: No such file or directory
MassTemplate.h:8:19: error: TFile.h: No such file or directory
masstmplibdict.cc:18:20: error: TClass.h: No such file or directory
masstmplibdict.cc:19:21: error: TBuffer.h: No such file or directory
masstmplibdict.cc:21:20: error: TError.h: No such file or directory

[quote=“pcanal”]Hi,

What is the compile line issued by your makefile when compiling your source file? What is the exact first error message you see?

Philippe[/quote]

Hi,

Did you set ROOTSYS to point to /home/sckao/root ?

Cheers,
Philippe

Hi

Yes, I have these 3 lines in my .bashrc file.

===========================
export ROOTSYS=/home/sckao/root
export PATH=$ROOTSYS/bin:$PATH
export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH

Thanks,
SC

[quote=“pcanal”]Hi,

Did you set ROOTSYS to point to /home/sckao/root ?

Cheers,
Philippe[/quote]

Strange.
What does ls -l /home/sckao/root/include/RConfig.h
returns?
What is the content of /home/sckao/root/config.status

Philippe.

Hi

[quote=“pcanal”]Strange.

What does ls -l /home/sckao/root/include/RConfig.h
returns?
-rw-r–r-- 1 sckao sckao 16180 2009-01-04 07:46 /home/sckao/root/include/RConfig.h

What is the content of /home/sckao/root/config.status
this one is empty …

Philippe.[/quote]

Hi,

What is the result of root-config --cflags
What is the result of gmake -n

Cheers,
Philippe.

Hi,

I’m actually going through the same thing as SC with my Makefile now (unable to find RConfig.h), so I thought I’d contribute my own code and results.

First, my Makefile is this:

ROOTCONFIG   := root-config
ROOTCFLAGS   := $(shell $(ROOTCONFIG) --cflags)
ROOTLDFLAGS  := $(shell $(ROOTCONFIG) --ldflags)
ROOTLIBS     := $(shell $(ROOTCONFIG) --libs)
ROOTGLIBS    := $(shell $(ROOTCONFIG) --glibs)
HASTHREAD    := $(shell $(ROOTCONFIG) --has-thread)

CXX           = g++
CXXFLAGS      = -O -Wall -fPIC $(ROOTCFLAGS)
LD            = g++
LDFLAGS       = -O $(ROOTLDFLAGS)
SOFLAGS       = -shared
LIBS          = $(ROOTLIBS) $(SYSLIBS)
GLIBS         = $(ROOTGLIBS) $(SYSLIBS)

libMyLib.so:   MyLibLinkDef.h
                @rootcint -f MyLibDict.cc -c MyLibLinkDef.h
                $(LD) $(LDFLAGS) $(SOFLAGS) MyLibDict.cc -o $@

I’m operating with 5.18 version attached to CMSSW. As it is
$ROOTSYS$/include/RConfig.h
exists; but
$ROOTSYS/config.status
doesn’t exist.

root-config --cflags returns this:

And gmake -n returns this:

Thanks,
Tom

Hi,

SC: your line
@$(LD) $(CXXFLAB) $(LIB) -o $@ $^
has two bugs, it should be
@$(LD) $(CXXFLAGS) -o $@ $^

Tom: the link line is wrong; it should be
$(CXX) $(LDFLAGS) $(SOFLAGS) $(CXXFLAGS) MyLibDict.cc -o $@
The CXX vs LD doesn’t matter in your case but you need to pass CXXFLAGS because compiling the .cc is one of the steps you request the compiler driver to do.

Cheers, Axel.

Hi Axel,

Thanks for the quick response. From my side, things now work :slight_smile:

There’s just one more change I needed to implement, which I’ll include here for posterity. For the case of my files, which include different types of map objects I want to use, I needed to make the following edit to my Makefile:

@rootcint -f MyLibDict.cc -c MyLibLinkDef.h

needed to get changed to

@rootcint -f MyLibDict.cc -c map.h MyLibLinkDef.h