Convert .cc to .root

Hi,
I tried to convert my .cc file to .root using script:
PROGNAME = analysis.e
SOURCEFILES = analysis.cc
OBJS = (patsubst %.cc, %.o, (SOURCEFILES))

ROOTCFLAGS := (shell root-config --cflags) ROOTLIBS := (shell root-config --libs)
ROOTGLIBS := $(shell root-config --glibs)

LDFLAGS = -O
LIBS += (ROOTLIBS) CFLAGS += (ROOTCFLAGS)

%.o: %.cc
g++ -Wall {CFLAGS} -c -g -o @ $<

(PROGNAME): (OBJS)
g++ -Wall -o @ (OBJS) (LDFLAGS) (LIBS)

test:
@echo $(ROOTCFLAGS)

clean:
-rm -f {PROGNAME} {OBJS}
but I got this error message:
g++ -Wall -o analysis.e analysis.o -O -L/usr/lib/x86_64-linux-gnu -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic
/usr/lib/gcc/x86_64-linux-gnu/5/…/…/…/x86_64-linux-gnu/crt1.o: In function _start': (.text+0x20): undefined reference tomain’
collect2: error: ld returned 1 exit status
GNUmakefile:17: recipe for target ‘analysis.e’ failed
make: *** [analysis.e] Error 1

What could be problem?

Thank you,
A.analysis.cc (4.4 KB)

.root files are not executables, they are the a format to contain data.

You want to compile C++ source code into an executable. For that, every C++ program needs a function named “main”, which is what will be called when it is executed. That is what the compiler is complaining about.

To fix this, create a main function, which calls your analysis function like so:

int main(){
  analysis();
    return 0;
}

Thank you very much!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.