Pythia8 and ROOT and compile

My CINT script is run, but when I try compile I have this error:

$ g++ cut_test.cxx `root-config --libs --cflags` -o cut_test22
In file included from /usr/include/Pythia8/ParticleDecays.h:21:0,
                 from /usr/include/Pythia8/Pythia8/HadronLevel.h:22,
                 from /usr/include/Pythia8/Pythia.h:18,
                 from /usr/include/root/TPythia8.h:69,
                 from cut_test.cxx:1:
/usr/include/Pythia8/Pythia8/TauDecays.h:76:3: error: 'HMEHiggsEven2TwoFermions' does not name a type
   HMEHiggsEven2TwoFermions          hmeHiggsEven2TwoFermions;
   ^
/usr/include/Pythia8/Pythia8/TauDecays.h:77:3: error: 'HMEHiggsOdd2TwoFermions' does not name a type
   HMEHiggsOdd2TwoFermions           hmeHiggsOdd2TwoFermions;
   ^
/usr/include/Pythia8/Pythia8/TauDecays.h:78:3: error: 'HMEHiggsCharged2TwoFermions' does not name a type
   HMEHiggsCharged2TwoFermions       hmeHiggsCharged2TwoFermions;
   ^
/usr/include/Pythia8/Pythia8/TauDecays.h:79:3: error: 'HMEUnpolarized' does not name a type
   HMEUnpolarized                    hmeUnpolarized;
   ^
In file included from /usr/include/Pythia8/Pythia8/ProcessLevel.h:18:0,
                 from /usr/include/Pythia8/Pythia.h:26,
                 from /usr/include/root/TPythia8.h:69,
                 from cut_test.cxx:1:
/usr/include/Pythia8/ProcessContainer.h:214:3: error: 'SigmaOniaSetup' does not name a type
   SigmaOniaSetup charmonium, bottomonium;
   ^

There is something fishy with your installation of Pythia8. You have Pythia header files in /usr/include/Pythia8 and in /usr/include/Pythia8/Pythia8 that are getting mixed. Probably from different versions.

I removed /usr/include/Pythia8/Pythia8 and I have error :

$ g++ cut_test.cxx `root-config --libs --cflags` -o cut_test22
/tmp/ccsylEYJ.o: In function `cut_test(int, int)':
cut_test.cxx:(.text+0x13d): undefined reference to `TPythia8::TPythia8()'
cut_test.cxx:(.text+0x158): undefined reference to `TPythia8::ReadString(char const*) const'
cut_test.cxx:(.text+0x16c): undefined reference to `TPythia8::ReadString(char const*) const'
cut_test.cxx:(.text+0x180): undefined reference to `TPythia8::ReadString(char const*) const'
cut_test.cxx:(.text+0x194): undefined reference to `TPythia8::ReadString(char const*) const'
cut_test.cxx:(.text+0x1a8): undefined reference to `TPythia8::ReadString(char const*) const'
/tmp/ccsylEYJ.o:cut_test.cxx:(.text+0x1bc): more undefined references to `TPythia8::ReadString(char const*) const' follow
/tmp/ccsylEYJ.o: In function `cut_test(int, int)':
cut_test.cxx:(.text+0x202): undefined reference to `TPythia8::Initialize(int, int, double)'
cut_test.cxx:(.text+0x24d): undefined reference to `TPythia8::EventListing() const'
collect2: error: ld returned 1 exit status

Yes. You need to link to the pythia library now by adding -lpythia8 in tour command.

I added -lpythia8

$ g++ cut_test.cxx `root-config --libs --cflags`  -lpythia8 -o cut_test22
/tmp/ccVJaC3C.o: In function `cut_test(int, int)':
cut_test.cxx:(.text+0x13d): undefined reference to `TPythia8::TPythia8()'
cut_test.cxx:(.text+0x158): undefined reference to `TPythia8::ReadString(char const*) const'
cut_test.cxx:(.text+0x16c): undefined reference to `TPythia8::ReadString(char const*) const'
cut_test.cxx:(.text+0x180): undefined reference to `TPythia8::ReadString(char const*) const'
cut_test.cxx:(.text+0x194): undefined reference to `TPythia8::ReadString(char const*) const'
cut_test.cxx:(.text+0x1a8): undefined reference to `TPythia8::ReadString(char const*) const'
/tmp/ccVJaC3C.o:cut_test.cxx:(.text+0x1bc): more undefined references to `TPythia8::ReadString(char const*) const' follow
/tmp/ccVJaC3C.o: In function `cut_test(int, int)':
cut_test.cxx:(.text+0x202): undefined reference to `TPythia8::Initialize(int, int, double)'
cut_test.cxx:(.text+0x24d): undefined reference to `TPythia8::EventListing() const'
collect2: error: ld returned 1 exit status

Sorry, I meant -lEGPythia8, which is the ROOT library implementing TPythia8::…

another problem:

$ g++ cut_test.cxx `root-config --libs --cflags` -lEGPythia8 -o cut_test22
/usr/bin/ld: cannot find -lEGPythia8
collect2: error: ld returned 1 exit status

What is output of " root-config --libs --cflags " ?

$ root-config --libs --cflags
-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 -pthread -m64 -I/usr/include/root

How did you install ROOT in your system? Are the ROOT libraries in /usr/lib/x86_64-linux-gnu? Did you enable pythia8?

I installed from Ubuntu repositories. (sudo apt-get install packages)

As I said the TPythia8 class is implemented in library libEGPythia8.so. If this library is not in your installation you will need to build from sources.

My CINT script is loaded in such a way:

 gSystem->Load("/usr/lib/x86_64-linux-gnu/libpythia8");
   gSystem->Load("libEG");
   gSystem->Load("libEGPythia8");

Assuming that you have “root-plugin-montecarlo-pythia8” and “pythia8-root-interface” packages installed, try:
-L/usr/lib/x86_64-linux-gnu/root5.34 -lEGPythia8

I try:

g++ cut_test.cxx `root-config --libs --cflags` -L/usr/lib/x86_64-linux-gnu/root5.34  -o cut_test22
/tmp/cc21Pyz3.o: In function `cut_test(int, int)':
cut_test.cxx:(.text+0x13d): undefined reference to `TPythia8::TPythia8()'
cut_test.cxx:(.text+0x158): undefined reference to `TPythia8::ReadString(char const*) const'
cut_test.cxx:(.text+0x16c): undefined reference to `TPythia8::ReadString(char const*) const'
cut_test.cxx:(.text+0x180): undefined reference to `TPythia8::ReadString(char const*) const'
cut_test.cxx:(.text+0x194): undefined reference to `TPythia8::ReadString(char const*) const'
cut_test.cxx:(.text+0x1a8): undefined reference to `TPythia8::ReadString(char const*) const'
/tmp/cc21Pyz3.o:cut_test.cxx:(.text+0x1bc): more undefined references to `TPythia8::ReadString(char const*) const' follow
/tmp/cc21Pyz3.o: In function `cut_test(int, int)':
cut_test.cxx:(.text+0x202): undefined reference to `TPythia8::Initialize(int, int, double)'
cut_test.cxx:(.text+0x24d): undefined reference to `TPythia8::EventListing() const'
collect2: error: ld returned 1 exit status

and where’s the library name?

$ g++ cut_test.cxx `root-config --libs --cflags` -L/usr/lib/x86_64-linux-gnu/root5.34 -lEGPythia8 -o cut_test22
//usr/lib/x86_64-linux-gnu/libpythia.so.8: undefined reference to `setlhaparm_'
//usr/lib/x86_64-linux-gnu/libpythia.so.8: undefined reference to `evolvepdfm_'
//usr/lib/x86_64-linux-gnu/libpythia.so.8: undefined reference to `initpdfsetbynamem_'
//usr/lib/x86_64-linux-gnu/libpythia.so.8: undefined reference to `initpdfm_'
//usr/lib/x86_64-linux-gnu/libpythia.so.8: undefined reference to `initpdfsetm_'
//usr/lib/x86_64-linux-gnu/libpythia.so.8: undefined reference to `evolvepdfphotonm_'
collect2: error: ld returned 1 exit status

Try:
-L/usr/lib/x86_64-linux-gnu/root5.34 -lEGPythia8 -llhapdfdummy

$ g++ cut_test.cxx `root-config --libs --cflags` -L/usr/lib/x86_64-linux-gnu/root5.34 -lEGPythia8 -llhapdfdummy -o cut_test22
//usr/lib/x86_64-linux-gnu/libpythia.so.8: undefined reference to `setlhaparm_'
//usr/lib/x86_64-linux-gnu/libpythia.so.8: undefined reference to `evolvepdfm_'
//usr/lib/x86_64-linux-gnu/libpythia.so.8: undefined reference to `initpdfsetbynamem_'
//usr/lib/x86_64-linux-gnu/libpythia.so.8: undefined reference to `initpdfm_'
//usr/lib/x86_64-linux-gnu/libpythia.so.8: undefined reference to `initpdfsetm_'
//usr/lib/x86_64-linux-gnu/libpythia.so.8: undefined reference to `evolvepdfphotonm_'
collect2: error: ld returned 1 exit status

Assuming that you have the “liblhapdf-dev” package installed, try:
-L/usr/lib/x86_64-linux-gnu/root5.34 -lEGPythia8 -lLHAPDF