Unable to run pythia8244 examples with ROOT6

ROOT Version: v6-22-02
Platform: Ubuntu 20.04.1 LTS

Hi, I am able to run pythia8.C in root/tutorials/pythia, but when I try to

make main91

it shows the following error

main91.cc:18:10: fatal error: TH1.h: No such file or directory
   18 | #include "TH1.h"
      |          ^~~~~~~
compilation terminated.
make: *** [Makefile:145: main91] Error 1

I configured pythia with --enable-shared and --with-root=root_install. I also add the following to Makefile in examples

main91: $$@.cc $(PREFIX_LIB)/libpythia8.a
ifeq ($(ROOT_USE),true)
        $(CXX) $< -o $@ -w $(CXX_COMMON)\
        `$(ROOT_BIN)/root-config --cflags`\
        -Wl,-rpath,`$(ROOT_BIN)/root-config --libdir` `$(ROOT_BIN)/root-config --glibs`
else
        @echo "Error: $@ requires ROOT"

I don’t know how to solve the problem. Any help will be appreciated!

A root include is missing. Check that the command line executed by make has -I<where root headers are>. It could be that root-config in your case cannot be found / that you have to source thisroot.sh.

I tried

make main91 -I $ROOTSYS/include

and saw the same error. I’m pretty sure that TH1.h file is in $ROOTSYS/include.
I also sourced thisroot.sh and it still doesn’t work.

Well, make doesn’t react to -I. Those commands are for the compiler, so they need to be in the Makefile.
Also note that root-config will generate the correct flags for the compiler:

$ root-config --cflags
-stdlib=libc++ -pthread -std=c++11 -m64 -I/Path/To/ROOT/include

Your makefile has a root-config line, but I’m not sure its executed correctly. Check e.g. that $ROOT_BIN leads somewhere meaningful.
That’s why I said that you have to check what command line make generates for your compiler. Make usually prints the lines, unless you silenced it. You can e.g. google how to un-silence make.

BTW:
You don’t have to be “pretty sure”, you can check:

ls $ROOTSYS/include/TH1.h

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