Pythia8 compliation error, Pythia8/Pythia.h not found

Hello Experts

I tried to install pythia on linux, but my program does not work, however the examples does

~/pythia/pythia8307/examples$ make ptu1
g++     ptu1.cc   -o ptu1
ptu1.cc:3:10: fatal error: Pythia8/Pythia.h: No such file or directory
    3 | #include "Pythia8/Pythia.h"
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [<builtin>: ptu1] Error 1

I also tried with: g++ -I/home/shrey/Downloads/pythia/pythia8307/include ptu1.cc -o ptu1 -lpythia8 -L/home/shrey/Downloads/pythia/pythia8307/lib

And still the same error.
Im relatively new to all this, any suggestions will help a lot.

Thanks

Hi @Shrey_Upadhyay ,

the compiler can’t find the Pythia8/Pythia.h header. The solution is usually to pass the path to the parent directory of the Pythia8 directory to the compiler with the -I option.

Does /home/shrey/Downloads/pythia/pythia8307/include contain Pythia8/Pythia.h?

Cheers,
Enrico

Thanks a lot for your reply

I was able to get pass the initial include error using:g++ -I/home/shrey/pythia/pythia8307/include ptu1.cc -o ptu1 -lpythia8 -L/home/shrey/pythia/pythia8307/lib' but now get another error when I try to run the program using ./ptu1
./ptu1: error while loading shared libraries: libpythia8.so: cannot open shared object file: No such file or directory
`
And yes /home/shrey/Downloads/pythia/pythia8307/include contain Pythia8/Pythia.h

Looking forward to your reply
Thanks

Can the issue be due to ROOT? I’ve also have it installed.
Can you please guide me on how to enable shared library in pythia

Thanks

Hi,

this is another common C++ compilation (or more precisely linking) issue which is not related to ROOT.
At runtime the program is looking for the libpythia8.so shared library and it can’t find it in the LD_LIBRARY_PATH. Adding /home/shrey/pythia/pythia8307/lib to your LD_LIBRARY_PATH is one way to solve this problem. Searching the web or stackoverflow for “error while loading shared libraries” should provide more context/info.

Cheers,
Enrico