SammyRob
SammyRob

Reputation: 59

Run Binary With Specific QT Version - Cannot mix incompatible Qt library

I'm trying to replicate an application that we currently have running on a physical Ubuntu server using an Ubuntu machine in Virtual Box. It is a QT application but on the server we are running it using pm2 from NPM. After installing QT, and installing drivers needed for the application i've tried to run it but keep coming across this error:

Cannot mix incompatible Qt library (version 0x50701) with this library (version 0x50905)

I've inherited the code from someone else and don't want to change the project to QT5.9.5, so i'm trying to run with 5.7.1, I've followed instructions on other questions in order to change the QT version to 5.7.1 but still get the same error when running it.

I followed the instructions here: https://unix.stackexchange.com/questions/116254/how-do-i-change-which-version-of-qt-is-used-for-qmake

When checking the QT version using "qmake -v" in the console I get the following output:

QMake version 3.0 Using Qt version 5.7.1 in /home/sam/Qt5.7.1/5.7/gcc_64/lib

So although it looks to me like i'm using the desired version of Qt (5.7.1), i'm still getting the incompatible library issue, i'm very new to all of this so apologies if this is a stupid question. If anyone could tell me what to do in order to use the compatible library that'd be great, thanks.

Upvotes: 2

Views: 1944

Answers (1)

Mr. Developerdude
Mr. Developerdude

Reputation: 9678

I will try to explain this in steps!

  1. Each complete set of Qt libraries is called a Qt "distribution". You can get Qt distributions from a variety of sources:

    • Installed from the package manager of your OS (.deb/.rpm).
    • From a downloaded zip file on http://qt.io
    • As a cloned repo from git
    • etc..
  2. Some of the available Qt distributions will come pre-built, and some will need to be built from sources. In either case they will all have a qmake program that is specific to that particular Qt distribution. This program is responsible for building programs so that they link to the particular Qt distribution that the qmake is part of. qmake is also used when building with QtCreator.

  3. If you have a binary built with one qmake and you try to run it on another computer, it might find the wrong Qt libraries during dynamic linking and spit out errors of "incompatible version of Qt".

There are many solutions to this problem;

  1. Collect all the Qt libraries (Mine are in /home/myusername/Qt/5.version/gcc_64/lib/*.so) in the same folder as your program executable. This will make sure they are prefered to any other version of Qt that may be in your dynamic linker's path.
  2. Uninstall the OS supplied Qt version(s). This may not be advisable especially if other programs use them.
  3. Rebuilt your program from source using the correct qmake.

Upvotes: 1

Related Questions