I am trying to write a makefile using root libraries. Makefile -
UNAME = $(shell uname)
EXE = trigVPATH = .:./interface
vpath %.h ./interfaceCSUF = 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-deprecatedLIBS =
HDRS = (wildcard interface/*.(HSUF))
HDRS_DICT = interface/PhysicsObjects.h interface/LinkDef.hbin: (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
-lTMVACreate 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.depClean
.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