Compilation error: cannot find lpythia8-pthread ROOT with Pythia 8


ROOT Version: 5.34.36
Platform: Ubuntu 18.04
Compiler: Not Provided


Hello Everyone,
I am trying to compile my code with the command:

g++ -std=c++11 forWong_main.cpp -o forWong `pythia8-config --cppflags --libs --cxxflags --lhapdf` `root-config --cflags --glibs`

which uses both ROOT and PYTHIA. I have ROOT 5.34.36 and PYTHIA8.180 installed and both of them should be configured in the correct way such that ROOT should have been linked to PYTHIA . However I got the error:

/usr/bin/ld: cannot find -lpythia8-pthread
collect2: error: ld returned 1 exit status
Makefile:4: recipe for target 'main' failed
make: *** [main] Error 1

I have no idea what the library pythia8-pthread is and it’s not in my pythia8 folder, and when I search for pthread, I can only find it under some subfolder of ROOT. I am a bit confused and I tried to reinstall pythia8 but nothing changed.

Then I tried the compilation command without --lhapdf (I wanted to link to lhapdf and I am not sure if I did it correctly or not either :frowning: )

g++ -std=c++11 forWong_main.cpp -o forWong `pythia8-config --cppflags --libs --cxxflags``root-config --cflags --glibs`

Then I get the following error:

/usr/bin/ld: cannot find -llhapdfdummy-pthread

I am not sure if it’s relevant but I set the following environment variables in my .bashrc file:

export PYTHIA8=/home/killua/pythia/pythia-build
export ROOTSYS=/home/ROOT
export PATH=$ROOTSYS/bin:$PATH
export PATH=${PATH}:/home/killua/pythia/pythia-build/bin
export LD_LIBRARY_PATH=$ROOTSYS/lib:$PYTHONDIR/lib:$ROOTSYS/bindings/pyroot:$LD$
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/home/killua/pythia/pythia-build/lib
export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/home/killua/pythia/pythia-build/lib
source $HOME/root/bin/thisroot.sh
export PYTHONDIR=$ROOTSYS
export PYTHIA8DATA=/home/killua/pythia/pythia-build/xmldoc
export PATH=${PATH}:/home/killua/pythia/pythia-build/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib

Thank you.

Replace:

... --cxxflags``root-config ...

with (add at least one space character):

... --cxxflags` `root-config ...

Thank you! I got rid of the error, can’t believe it’s because of the syntax…
However, when I run my code, i used compilation command:

g++ -std=c++11 forWong_main.cpp -o forWong `pythia8-config --cppflags --libs --cxxflags --lhapdf` `root-config --cflags --glibs` -L/usr/lib/x86_64-linux-gnu/root5.34 -lEGPythia8 -lLHAPDF

It compiles successfully and then I run the executable with the following command:

./forWong forWong.cmnd > forWong.out

Then I get

./forWong: error while loading shared libraries: libpythia8.so: cannot open shared object file: No such file or directory
Makefile:7: recipe for target 'run' failed
make: *** [run] Error 127

Then I saw this thread Pythia example does not work and I tried the command

ldd `root-config --libdir`/libEG*so | grep -i pythia

I got

/home/killua/root/lib/libEGPythia8.so:
	libpythia8.so => not found

So I tried find ${PYTHIA8} -name "lib[pP]ythia*" -print
Then got

/home/killua/pythia/pythia-build/lib/libpythia8.so
/home/killua/pythia/pythia-build/lib/archive/libpythia8.a

Can you please let me know how to proceed?

Thank you very much!!!

Check:

echo ${LD_LIBRARY_PATH}

Hello,

I then tried set the environment variables again in the terminal, then I got a new error:

./forWong: error while loading shared libraries: libLHAPDF.so.0: cannot map zero-fill pages
Makefile:7: recipe for target 'run' failed
make: *** [run] Error 127

I fixed the above error by move liaLHAPDF.so to pythia/lib :slight_smile: This might not be the best thing to do but it fixed my error…

Hey @waclewacle,

that’s great, but for the future you can read up on how LD_LIBRARY_PATH and the linker flags for the compiler (like -L and -l) work.

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