code_fodder code_fodder - 6 months ago 34
Linux Question

error while loading shared libraries: libQt5Multimedia.so.5: cannot open shared object file: No such file or directory

I have a 32-bit linux Virtual Box which I am compiling my Qt c++ code on.

I am copying the target files to a 64-bit linux box (the 32-bit executable should still run on this PC).

The build is using dynamic linking, so I was going to start copying across the Qt lib files that I need. I planned to just do this manually by running the program and letting it tell me which lib files are missing + I know many of the files that I need so it won't take me long (normally).

So in my 64-bit box target folder I have the files:

Rpe


So I run my executable called "Rpe" and it complains:

./Rpe: error while loading shared libraries: libQt5Multimedia.so.5: cannot open shared object file: No such file or directory


I expected this to happen, then I go and copy the file libQt5Multimedia.so.5 from my 32-bit linux qt lib folder into the target directory on my 64-bit linux box. In my target folder I now have the files:

Rpe
libQt5Multimedia.so.5


I now run the Rpe executable again and I expect it to complain about a different lib file, however it is still complaining about the same
libQt5Multimedia.so.5
file not being found.

What am I doing wrong here?

EDIT-1

LDD output:

adadacha@duanedibbley:~/sandbox$ ldd Rpe
linux-gate.so.1 => (0xf7731000)
libQt5Multimedia.so.5 => not found
libQt5Network.so.5 => not found
libQt5Xml.so.5 => not found
libQt5Core.so.5 => not found
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xf7616000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xf75f9000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf744a000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf7404000)
/lib/ld-linux.so.2 (0x5661f000)
adadacha@duanedibbley:~/sandbox$

Answer

I would create a directory for your "product" with the executable in a bin sub-directory and the Qt libraries (and any other libraries) in a lib sub-directory.

In the parent directory I would add a wrapper script to set $LD_LIBRARY_PATH and execute the binary (not tested):

#!/bin/sh
dirname="$(dirname "$0")"
exename="$(basename "$0")"

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$dirname/lib"
export LD_LIBRARY_PATH
exec "$dirname/bin/$exename" $*
Comments