Linux run program if install two version Qt

  • I built version 5.4.2 of my program, if I run it on a PC, all is well. ldd command =>  (0x00007fffdabe8000) => /usr/lib/ (0x00007f3e26600000) => /home/red_spider/Qt5.4.2/5.4/gcc_64/lib/ (0x00007f3e25d78000) => /home/red_spider/Qt5.4.2/5.4/gcc_64/lib/ (0x00007f3e25798000) => /home/red_spider/Qt5.4.2/5.4/gcc_64/lib/ (0x00007f3e24fc8000) => /home/red_spider/Qt5.4.2/5.4/gcc_64/lib/ (0x00007f3e24da0000) => /home/red_spider/Qt5.4.2/5.4/gcc_64/lib/ (0x00007f3e24788000) => /home/red_spider/Qt5.4.2/5.4/gcc_64/lib/ (0x00007f3e24420000) => /home/red_spider/Qt5.4.2/5.4/gcc_64/lib/ (0x00007f3e241e0000) => /home/red_spider/Qt5.4.2/5.4/gcc_64/lib/ (0x00007f3e23fa0000) => /home/red_spider/Qt5.4.2/5.4/gcc_64/lib/ (0x00007f3e23860000) => /usr/lib/x86_64-linux-gnu/ (0x00007f3e23558000) => /lib/x86_64-linux-gnu/ (0x00007f3e23340000) => /lib/x86_64-linux-gnu/ (0x00007f3e22f78000) => /lib/x86_64-linux-gnu/ (0x00007f3e22d58000) => /lib/x86_64-linux-gnu/ (0x00007f3e22b38000) => /usr/lib/x86_64-linux-gnu/ (0x00007f3e228e0000) => /lib/x86_64-linux-gnu/ (0x00007f3e225d8000) => /usr/lib/x86_64-linux-gnu/ (0x00007f3e222a0000) => /lib/x86_64-linux-gnu/ (0x00007f3e21f98000) => /usr/lib/nvidia-304/ (0x00007f3e21c78000) => /home/red_spider/Qt5.4.2/5.4/gcc_64/lib/ (0x00007f3e21828000) => /home/red_spider/Qt5.4.2/5.4/gcc_64/lib/ (0x00007f3e21498000) => /lib/x86_64-linux-gnu/ (0x00007f3e21290000) => /usr/lib/x86_64-linux-gnu/ (0x00007f3e21088000) => /lib/x86_64-linux-gnu/ (0x00007f3e20e80000)
        /lib64/ (0x00007f3e26860000) => /usr/lib/x86_64-linux-gnu/ (0x00007f3e20c78000) => /lib/x86_64-linux-gnu/ (0x00007f3e20a38000) => /usr/lib/x86_64-linux-gnu/ (0x00007f3e20818000) => /usr/lib/nvidia-304/tls/ (0x00007f3e20610000) => /usr/lib/nvidia-304/ (0x00007f3e1e220000) => /usr/lib/x86_64-linux-gnu/ (0x00007f3e1e008000) => /home/red_spider/Qt5.4.2/5.4/gcc_64/lib/ (0x00007f3e1c980000) => /usr/lib/x86_64-linux-gnu/ (0x00007f3e1c778000) => /usr/lib/x86_64-linux-gnu/ (0x00007f3e1c570000)

    if install my packages for ubuntu 15.04 (there is already a version 5.4.1) and run ldd..... =>  (0x00007ffe507f2000) => /usr/lib/ (0x00007fd675298000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd674bf0000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd674800000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd6742b0000) => /usr/lib/ (0x00007fd674088000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd673c50000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd673af0000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd673aa8000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd673a68000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd673520000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd673210000) => /lib/x86_64-linux-gnu/ (0x00007fd672ff8000) => /lib/x86_64-linux-gnu/ (0x00007fd672c28000) => /lib/x86_64-linux-gnu/ (0x00007fd672a08000) => /lib/x86_64-linux-gnu/ (0x00007fd6727e8000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd672590000) => /lib/x86_64-linux-gnu/ (0x00007fd672280000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd671f40000) => /lib/x86_64-linux-gnu/ (0x00007fd671c38000) => /lib/x86_64-linux-gnu/ (0x00007fd671a10000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd6717b8000) => /usr/lib/x86_64-linux-gnu/mesa/ (0x00007fd671518000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd671300000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd670ee8000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd670b68000) => /lib/x86_64-linux-gnu/ (0x00007fd670960000) => /lib/x86_64-linux-gnu/ (0x00007fd670758000)
    /lib64/ (0x00007fd6754f0000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd670550000) => /lib/x86_64-linux-gnu/ (0x00007fd6702e0000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd6700c0000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66fe18000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66fbf8000) => /lib/x86_64-linux-gnu/ (0x00007fd66f9c8000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66f798000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66f580000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66f378000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66f170000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66ef68000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66ed50000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66eb48000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66e940000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66e738000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66e530000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66e328000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66e120000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66df10000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66c6a0000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66c498000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd66c290000)

    loads the wrong versions of libraries => /usr/lib/x86_64-linux-gnu/ (0x00007fd670ee8000) => /usr/lib/x86_64-linux-gnu/ (0x00007fd670b68000)

    and error when run the program

    Cannot mix incompatible Qt library (version 0x50402) with this library (version 0x50401)
    Aborted (core dumped)

    or you can specify which version to use libraries?

  • Lifetime Qt Champion


    IIRC, you can use LD_LIBRARY_PATH to prepend a path to search for libraries when starting your application. Something like:

    LD_LIBRARY_PATH=/home/red_spider/Qt5.4.2/5.4/gcc_64/lib/ ./yourCoolProgram

    Depending on your needs, creating a little launcher script doing that will be simpler to start your application.

    Hope it helps

  • Thank you for your response

    I know this method, but it would avoid
    I create .deb package and install all the libraries in / usr/lib

    I just solved this problem)) I moved the library with /usr/lib in /usr/lib/x86_64-linux-gnu

    perhaps it is not the best option....
    the best solution would be to program sought specific version library.

  • Lifetime Qt Champion

    No it's not at all, you are overwriting system libraries.

    Again, if you want to use a specific set of libraries, use a launcher script and set LD_LIBRARY_PATH. That's the right thing to do.

    But since you want to integrate that in a debian environment, why not just use the installed version of Qt ?

  • @SGaist

    This problem ..
    because the program should work on different versions Kubuntu 14.04 used Qt 4.8.6, Kubuntu 15.04 used Qt 5.4.1
    program should massively distributed, and then there will be problems ...

    maybe you're right and will have to use LD_LIBRARY_PATH

    but I do not quite understand why Qt is not looking for the correct version.

  • Moderators

    @red_spider said:

    but I do not quite understand why Qt is not looking for the correct version.

    That's because you have multiple versions of Qt in your system that are visible to your application. The application doesn't know which is the correct version, so it loads the first one it finds.

    This is not a Qt problem -- the same thing could happen with any other library. On Windows, this is called DLL Hell.

    See for alternate ways to deploy your files. Personally, I like to use RPATH.

  • @JKSH thank you
    I add

    QMAKE_LFLAGS += -Wl,-rpath /opt/libitems/libx64/

    and it works )))
    Thank you all for your help.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.