title: Makefile: (.text+0x20): undefined reference to `main' collect2: error: ld returned 1 exit status
body: <p>I have a problem with a <code>Makefile</code>. Maybe the problem is the linker, but I can't
  find the error. At some point <code>(CXX) $(CXXFLAGS) $(LDFLAGS) $^ $(ROOTLIBS) -o @</code></p>
  
  <pre><code>(.text+0x20): undefined reference to `main'
  collect2: error: ld returned 1 exit status
  Makefile:65: recipe for target 'doMyAnalysisHeavyIon' failed
  make: *** [doMyAnalysisHeavyIon] Error 1
  </code></pre>
  
  <p><code>Makefile</code>:</p>
  
  <pre><code>  1 all: libs programs
    2 
    3 libs: HxSimParticle_cxx.so HxSimEvent_cxx.so
    4 
    5 programs  = doMyAnalysisHeavyIon
    6 
    7 #LHAPDF    = LHAPDF-6.1.6
    8 PYTHIA8   = /home/andre/pythia8235
    9 HXPATH    = /home/andre/pythia8235/examples/Analysis
   10 
   11 # define compiler/linker flags
   12 CXX       = g++
   13 
   14 CXXFLAGS  = -O3 -Wall -fPIC
   15 CXXFLAGS += $(shell root-config --cflags)
   16 CXXFLAGS += $(shell fastjet-config --cxxflags)
   17 CXXFLAGS += -I$(HXPATH)
   18 
   19 #LDFLAGS   = -O3
   20 LDFLAGS   = -O3 -Wl,-rpath,'$(HXPATH)'
   21 LDFLAGS  += $(shell root-config --ldflags)
   22 #LDFLAGS  += -Wl,-rpath,$(PYTHIA8)/lib/
   23 #LDFLAGS  += -Wl,-rpath,$(HXPATH)/
   24 
   25 SOFLAGS   = -shared
   26 
   27 ROOTLIBS  = $(shell root-config --libs --glibs --evelibs)
   28 #ROOTLIBS += -lEG -lGui -lASImage -lASImageGui
   29 
   30 #PDFLIBS   = $(shell ${LHAPDF}/install/bin/lhapdf-config --libs)
   31 #P8LIBS     = $(shell $(PYTHIA8)/bin/pythia8-config --libs)
   32 
   33 #HXLIBS    = $(HXPATH)/HxSimParticle_cxx.so $(HXPATH)/HxSimEvent_cxx.so
   34 
   35 PROGRAMS = doMyAnalysisHeavyIon
   36 
   37 # compile/link HxSimEvent
   38 HxSimEvent_cxx.so: HxSimEventDict.o HxSimEvent.o HxSimParticleDict.o HxSimParticle.o
   39         $(CXX) $(SOFLAGS) $(LDFLAGS) $^ $(ROOTLIBS) -o $@ 
   40 
   41 HxSimEvent.o: HxSimEvent.cxx
   42         $(CXX) $(CXXFLAGS) -c $^ -o $@ 
   43 
   44 HxSimEventDict.o: HxSimEventDict.cxx
   45         $(CXX) $(CXXFLAGS) -c $^ -o $@ 
   46 
   47 HxSimEventDict.cxx: HxSimEvent.h HxSimEventLinkDef.h
   48         rootcint -f $@ -c $(CXXFLAGS) -p $^
   49 
   50 # compile/link HxSimParticle
   51 HxSimParticle_cxx.so: HxSimParticleDict.o HxSimParticle.o
   52         $(CXX) $(SOFLAGS) $(LDFLAGS) $^ $(ROOTLIBS) -o $@ 
   53 
   54 HxSimParticle.o: HxSimParticle.cxx
   55         $(CXX) $(CXXFLAGS) -c $^ -o $@ 
   56 
   57 HxSimParticleDict.o: HxSimParticleDict.cxx
   58         $(CXX) $(CXXFLAGS) -c $^ -o $@ 
   59 
   60 HxSimParticleDict.cxx: HxSimParticle.h HxSimParticleLinkDef.h
   61         rootcint -f $@ -c $(CXXFLAGS) -p $^
   62 
   63 # compile/link doMyAnalysisHeavyIon 
   64 doMyAnalysisHeavyIon: doMyAnalysisHeavyIon.o HxSimEvent_cxx.so HxSimParticle_cxx.so
   65         $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ $(ROOTLIBS) -o @
   66 
   67 doMyAnalysisHeavyIon.o: doMyAnalysisHeavyIon.C
   68         $(CXX) $(CXXFLAGS) -c $^ -o $@
   69 
   70 .PHONY: clean distclean
   71 
   72 # remove object files
   73 clean:
   74         @rm -f *.o
   75 
   76 # remove objects, libraries and dicts
   77 distclean: clean
   78         @rm -f *.so *Dict.* $(PROGRAMS)
  </code></pre>