Please nominate your Qt Champions for 2021!

Deploying on linux, executable cannot find shared library at runtime?

  • I have developed an application that works on Windows and I am working on getting it working on Linux. I have been able to link the libraries during compilation but I am unable to get them to work at runtime.

    I have looked everyone on the internet and I have implemented what I believe is the correct approach but unfortunately it does not seem to work no matter what I try.

    when running ldd on the binary It shows that it cannot find the libraries despite changing the location for which it should be looking. => (0x00007fff757f5000) => not found => /usr/lib64/ (0x00000038b8e00000) => /usr/lib64/ (0x00000038b4e00000) => /usr/lib64/ (0x00007f76a89ee000) => /usr/lib64/ (0x00000038b7600000) => /usr/lib64/ (0x00000038b6e00000) => not found => not found => not found => not found => not found => not found => not found => not found => not found => not found => /usr/lib64/ (0x00000038c0200000) => /lib64/ (0x00000038b2a00000) => /usr/lib64/ (0x00000038bd200000)

    I have implemented this in my project file but unfortunately It does not do anything.

    path/to/project/bin <- where the binary is.
    path/to/project/lib <- where the library files are.

    linux {
    QMAKE_LFLAGS += '-Wl,-rpath,\'\$$ORIGIN/../lib\''

    Can anyone work out what I have done wrong?

  • Lifetime Qt Champion

  • Lifetime Qt Champion


    You can use a qt.conf file to say where the libraries are.

    For testing purpose, another way is to set the LD_LIBRARY_PATH environment variable to the path where the .libraries can be found.

  • Did you tried to use QMAKE_RPATHDIR that doesn't need to explicitly set compiler flags ??

    Also, did you try to run "readelf -d <binary>" to see if the RPATH has been correctly configured into the application binary ??

Log in to reply