Hi,
Sorry this probably really poor question but after a fair few hours I thought I would ask. Sorry for the poor form as well. I can post the files if needed. I’m rather new to making Makefiles and I’m try to make an executable for a c++ file named PixelTPC_DAQDecoder.cc. This file has a few dependancies Event.h and Channelnfo.h. I am trying to make a dictionary for these dependancies because I am putting Event() (Class is in Event.h) objects into a TTree. Following this page https://root.cern.ch/faq/how-generate-dictionary I have created the makefile. below. However I get the following error:
> Building Objectfile /home/argonshef/LArAnalysis/srcs/../build/obj/PixelTPC_DAQDecoder.so
>g++ -o /home/argonshef/LArAnalysis/srcs/../build/obj/PixelTPC_DAQDecoder.so `root-config --ldflags` `root-config --cflags --glibs` -I/home/argonshef/root-6.08.00/builddir/include PixelTPC_DAQDecoder.cc EventDict.cxx ChannelInfo.c -lCAENDigitizer
>Compiling Exectuable /home/argonshef/LArAnalysis/srcs/../build/exe/PixelTPC_DAQDecoder
>`root-config --cxx` /home/argonshef/LArAnalysis/srcs/../build/obj/PixelTPC_DAQDecoder.so -Wall `root-config --glibs` -o /home/argonshef/LArAnalysis/srcs/../build/exe/PixelTPC_DAQDecoder
>/home/argonshef/LArAnalysis/srcs/../build/obj/PixelTPC_DAQDecoder.so: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o:(.text+0x0): first defined here
/home/argonshef/LArAnalysis/srcs/../build/obj/PixelTPC_DAQDecoder.so: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o:(.fini+0x0): first defined here
/home/argonshef/LArAnalysis/srcs/../build/obj/PixelTPC_DAQDecoder.so: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o:(.data+0x0): first defined here
/home/argonshef/LArAnalysis/srcs/../build/obj/PixelTPC_DAQDecoder.so: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o:(.init+0x0): first defined here
/home/argonshef/LArAnalysis/srcs/../build/obj/PixelTPC_DAQDecoder.so:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o:(.rodata.cst4+0x0): first defined here
/usr/bin/ld: error in /home/argonshef/LArAnalysis/srcs/../build/obj/PixelTPC_DAQDecoder.so(.eh_frame); no .eh_frame_hdr table will be created.
collect2: error: ld returned 1 exit status
make: *** [/home/argonshef/LArAnalysis/srcs/../build/exe/PixelTPC_DAQDecoder] Error 1
Here is the MakeFile. I do not understand where I duplicate a main? Can explain what I am doing wrong.
Cheers
Dom
SHELL = /bin/sh
SRCDIR = $(shell echo $$LArAnASRCDir)
BASEDIR = $(SRCDIR)..
CC = g++
CXX = `root-config --cxx`
CPPFLAGS = `root-config --cflags --glibs`
LDFLAGS = `root-config --ldflags`
LIBS = `root-config --glibs`
COPTS = -std=c++11
OBJDIR = $(shell echo $$LArANAOBJDir)
OUTDIR = $(shell echo $$LArANAEXEDir)
DEPS = ./Event.h ./ChannelInfo.h
SRCFILES = PixelTPC_DAQDecoder.cc
OBJFILES = $(patsubst %.cc, $(OBJDIR)/%.so, $(SRCFILES))
EXECUTABLES = $(patsubst %.cc, $(OUTDIR)/%, $(SRCFILES))
all: $(EXECUTABLES)
.PRECIOUS: $(OBJFILES)
$(OBJDIR)/%.so: %.cc EventDict.cxx ChannelInfo.c
@echo Building Objectfile $@
@mkdir -p $(@D)
g++ -o $@ $(LDFLAGS) $(CPPFLAGS) -I$(ROOTSYS)/include $^ -lCAENDigitizer
$(OUTDIR)/%: $(OBJDIR)/%.so
@echo Compiling Exectuable $@
@mkdir -p $(@D)
$(CXX) $< -Wall $(LIBS) -o $@
.PHONY: clean
clean:
@rm -f ./*~ $(OBJFILES) $(EXECUTABLES)
EventDict.cxx: $(DEPS) Linkdef.h
@echo "Generating dictionary ..."
rootcint -f $@ -c $(CPPFLAGS) -p $^