I am trying to compile/create an so file based on old hsimple.C tutorial.
The following compiles and generates the executable but it segfaults on ./main
Surely, I am missing lots of libraries… Is there an automated way to generate the list of so files needed?
g++ -std=c++11 -c -I${ROOTSYS}/include ${ROOTSYS}/tutorials/hsimple.C -o ./hsimple.o
g++ -v -std=c++11 -I$ROOTSYS/include -L$ROOTSYS/lib mainSimple1.cxx -lCore -lHist -lCling -lRIO -lTree -lUnuran -lGpad -lMathCore hsimple.o -o main./main
Thanks
Claude
Hi, Claude.
You certainly can. You can use
root-config --cflags
root-config --ldflags
root-config --libs
Then just modify your calls to g++ accordingly:
g++ -std=c++11 -c `root-config --cflags` ${ROOTSYS}/tutorials/hsimple.C -o ./hsimple.o
Hi,
just as a note, depending on the compiler you might have to move the root-config --cflags --libs argument to the end of the gcc invocation: libraries required by compilation targets should be listed after the targets that require them, as per gcc’s documentation of the -l option.
So I would go with this:
g++ -c ${ROOTSYS}/tutorials/hsimple.C $(root-config --cflags --libs)
Cheers,
Enrico
Ah, good call. I know Ubuntu can be a pain about that.