Pythia8 and ROOT and compile

$ sudo apt-get install liblhapdf-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
liblhapdf-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 452 not upgraded.
pioflor@pioflor-IdeaPad-S210-Touch:~/root$ g++ cut_test.cxx `root-config --libs --cflags` -L/usr/lib/x86_64-linux-gnu/root5.34 -lEGPythia8  -lLHAPDF -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

Two last trials (assume that the “libpythia8-dev” package is installed):
-L/usr/lib/x86_64-linux-gnu/root5.34 -lEGPythia8 -lpythia8 -llhapdfdummy
-L/usr/lib/x86_64-linux-gnu/root5.34 -lEGPythia8 -lpythia8 -lLHAPDF

You can also try to add “-Wl,–no-as-needed” somewhere in the beginning of your g++ command line (BEFORE any libraries appear in it).

I don’t quite understand. What should I enter in the command line?

Try:
g++ cut_test.cxx -Wl,–no-as-needed root-config --libs --cflags -L/usr/lib/x86_64-linux-gnu/root5.34 -lEGPythia8 -lpythia8 -llhapdfdummy -o cut_test22
g++ cut_test.cxx -Wl,–no-as-needed root-config --libs --cflags -L/usr/lib/x86_64-linux-gnu/root5.34 -lEGPythia8 -lpythia8 -lLHAPDF -o cut_test22

It works! Thank You!

And with “-lpythia8” but without “-Wl,–no-as-needed” (I think it’s better not to use this flag unless you do really really need it)?