Makefile Issue with root libraries

I am trying to write a makefile using root libraries. Makefile -

UNAME = $(shell uname)
EXE = trig

VPATH = .:./interface
vpath %.h ./interface

CSUF = cc
HSUF = h
DICTC = Dict.(CSUF) DICTH = (patsubst %.(CSUF),%.h,(DICTC))

#SRCS = (wildcard src/*.(CSUF))
SRCS = src/PhysicsObjects.cc src/AnaBase.cc src/MuonTriggerEfficiency.cc src/MVASkim.cc
OBJS = (patsubst %.(CSUF), %.o, $(SRCS))

LDFLAGS = -g
SOFLAGS = -shared
CXXFLAGS = -I./interface -I./

CXX = g++
CXXFLAGS += -Wall -Wno-deprecated

LIBS =

HDRS = (wildcard interface/*.(HSUF))
HDRS_DICT = interface/PhysicsObjects.h interface/LinkDef.h

bin: (EXE) all: gmake cint gmake bin cling: (DICTC)

(DICTC): (HDRS_DICT)
@echo “Generating dictionary (DICTC) and (DICTH) …”
rootcint -f @ -c (CXXFLAGS) ^ # rootcling -f @ -rmf interface/AnalysisSpaceTreeMaker_xr.rootmap -c (CXXFLAGS) ^
perl -pi -e ‘s#interface/##’ (DICTH) @mv (DICTC) src/
@mv $(DICTH) interface/

(EXE): (OBJS) src/Dict.o
(CXX) (LDFLAGS) ^ -o @ $(LIBS) root-config --libs -lTMVA

Create object files

%.o : %.(CSUF) (CXX) (CXXFLAGS) `root-config --cflags` -o @ -c $<

makedepend

depend: (SRCS:.(CSUF)=.(CSUF).dep) @cat (notdir ^) > Makefile.dep @-rm -f (notdir ^) (patsubst %,%.bak,(notdir ^))
%.dep:
@touch (notdir @)
rmkdepend -f$(notdir @) -- (CXXFLAGS) root-config --cflags – $*
include Makefile.dep

Clean

.PHONY : clean
clean :
@-rm (OBJS) (EXE) interface/(DICTH) src/(DICTC) src/*.o

I could not get around the error-

/usr/lib/…/lib64/crt1.o: In function _start': (.text+0x20): undefined reference to main’
collect2: error: ld returned 1 exit status

Also tested with this - Makefile.txt (441 Bytes) getting the same error of undefined reference.

Kindly suggest me if I am missing any components.

Thanks,
Amandip

Hi Amandip,

are you sure a main function is defined in all the files you want to make executables from?

Cheers,
D

Hi dpiparo,

Thanks for your comment. Defining main in separate files for the src 's and including objects solved the issue.

cheers,
Amandip