ROOT ignores $PYTHIA8_INCLUDE_DIR and instead, looks only into the /usr/include

ROOT Version: 6.26/10
Platform: Fedora 37
Compiler: GCC 12.2.1


Hi,
As Fedora lags behind new Pythia8 versions (8.306 instead of 8.309) I have to build Pythia8 myself and, inevitably, ROOT from source as well. Everything builds seemingly OK, following instructions from both, Pythia8 and ROOT sides (I certainly had to make fix according to https://root-forum.cern.ch/t/include-code-h-and-python-3-11/52425).

Tests work as it should, but then it turns out that ROOT picks Pythia8’s headers from /usr/include rather than from the new Pythia8 installation, as I defined in $PYTHIA8_INCLUDE_DIR. In particular, it does not find Pythia8/PythiaParallel.h, which is new, but of course, finds the old Pythia8/Pythia.h.

The configuration seems appropriate:

# root-config --has-pythia8
yes
# root-config --config | grep PYTHIA8
... PYTHIA8_INCLUDE_DIR=<workdir>/pythia8309/include PYTHIA8_LIBRARY=<workdir>/pythia8309/lib/libpythia8.so ...

I’m just wondering, how should I instruct ROOT to use the proprietary installation of Pythia8?

Many thanks!

Try with: cmake -Dpythia8=ON -DPYTHIA8_DIR=<workdir>/pythia8309 /path/to/ROOT/source

If you still have problems, try to uninstall the “old” system default packages.

Following your advice, I’ve uninstalled the “old” system default Pythia8 packages and built ROOT once more, entirely from scratch. And now, expectedly, even 'Pythia8/Pythia.h' file not found (because /usr/include/Pythia8 does not exist any more…).

The root-config reply is invariably correct, as before.

So probably there is some problem somewhere in the cmake-related files.

At some point, I even tried to remove line 22: /usr in <workdir>/root_src/cmake/modules/FindPythia8.cmake (and rm <workdir>/root_build/CMakeCache.txt and again cmake), but it did not help either.

I tried the simple “cmake” configuration line given in my previous post and it worked fine (and then I was also able to successfully “make” ROOT with my own “<workdir>/pythia8309” version, of course):

(...)
-- Looking for Pythia8
-- Found Pythia8: <workdir>/pythia8309/include
(...)
-- Enabled support for: (...) pythia8 (...)
(...)

BTW. Building ROOT “from scratch” means removing the old “build directory” first.

Please let me know what happens if in a root session, you paste:
#include "Pythia8/PythiaParallel.h"

In principle, in ROOT, you should use its built-in interface:

ROOT → Functional Parts → Monte Carlo → Pythia8

There exists an example:

${ROOTSYS}/tutorials/pythia/pythia8.C

If you want to play with the “raw” PYTHIA 8 routines, try to create a simple “rootlogon.C” file (in your current working directory):

{ // rootlogon.C
  {
    char *path;
    if (!gSystem->Getenv("PYTHIA8")) {
      path = gSystem->ExpandPathName("<workdir>/pythia8309"); // path to PYTHIA 8 installation
      gSystem->Setenv("PYTHIA8", path); delete path;
    }
    if (!gSystem->Getenv("PYTHIA8DATA")) {
      path = gSystem->ExpandPathName("$(PYTHIA8)/share/Pythia8/xmldoc");
      gSystem->Setenv("PYTHIA8DATA", path); delete path;
    }
    path = gSystem->ExpandPathName("$(PYTHIA8)/include");
    gInterpreter->AddIncludePath(path); delete path;
#if 0 /* 0 or 1 */
    path = gSystem->ExpandPathName("$(PYTHIA8)/lib");
    gSystem->AddDynamicPath(path); delete path;
#endif /* 0 or 1 */
  }
  gSystem->Load("libEG"); gSystem->Load("libEGPythia8");
}

You will also need this “rootlogon.C” file (or something “equivalent”) if you want to compile ROOT macros with ACLiC and PYTHIA 8 is not installed in “standard system directories” (i.e., include files not in “/usr/include”).

Thanks a lot! I’ll give it a try.

But in fact, without your rootlogon.C,
root -b 'pythia8.C'
works, while
root -b 'pythia8.C+'
already does not:
<workdir>/root_build/include/TPythia8.h:69:10: fatal error: 'Pythia8/Pythia.h' file not found

So IMHO, there is still some bug in the current ROOT configuring procedure, so to say, because in the “official” Fedora supply of ROOT + Pythia8 everything works without any additional effort. Both, based on TPythia8 and on the native Pythia8 interfaces.

I wish they followed the latest versions of Pythia8.

See the PYTHIA 8README” file. You can set the absolute path to a directory to which “sudo make install” will copy the “bin”, “lib”, “include”, and “share” directories, e.g., try: ./configure --prefix=/usr ...

Simple, elegant – and correct. Thanks a lot! And for your time!

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