# Cannot mix incompatible Qt library...



## Emrion (May 3, 2020)

Have you ever had a Qt based application that doesn't want to run, just after an upgrade of the said app?
If you type the executable in a command line, you might receive something like: 





> Cannot mix incompatible Qt library (xxxxx) with this library (xxxxx)



The easy solution is: `pkg upgrade`. It always works (or almost).

But what if you can't upgrade all your packages? I encounter this situation because of the great new xorg-server-1.20...

So, what's the problem exactly? If you search into Qt sources (Qt5 5.14.2 here), you will find in corelib/kernel/qobject_p.h this snippet:

```
/*
    Catch mixing of incompatible library versions.
    Should be called from the constructor of every non-final subclass
    of QObjectPrivate, to ensure we catch incompatibilities between
    the intermediate base and subclasses thereof.
*/
inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) const
{
#if defined(QT_BUILD_INTERNAL)
    // Don't check the version parameter in internal builds.
    // This allows incompatible versions to be loaded, possibly for testing.
    Q_UNUSED(version);
#else
    if (Q_UNLIKELY(version != QObjectPrivateVersion)) {
        qFatal("Cannot mix incompatible Qt library (%d.%d.%d) with this library (%d.%d.%d)",
                (version >> 16) & 0xff, (version >> 8) & 0xff, version & 0xff,
                (QObjectPrivateVersion >> 16) & 0xff, (QObjectPrivateVersion >> 8) & 0xff, QObjectPrivateVersion & 0xff);
    }
#endif
}
```

You can check the Qt dependencies of your app but you're unlikely to find where the problem lies. They all get upgraded with the upgrade of the app.

Nevertheless, from my understanding, as all father objects must check the version of the legacy ones, it means that, for instance, if qt5-gui is needed by your app, it uses itself qt5-network and qt5-dbus. So, if there are not of the same version than qt5-gui, you will receive this error.

The solution is to get upgrade for qt_X_-things that aren't of the same version than qt_X_-core (qt5-core for now).

`pkg info | grep ^qt5`

There are some exceptions like qt5-webkit, but you can try to upgrade it anyway.


----------



## ahrkahrg (Jul 9, 2022)

I am running FreeBSD 13.
I have Smb4k & telegram. After installing subversion, I encountered an incompatibility with Firefox, Telegram and Smb4K.
Incompatibility between Qt5.15.5 and Qt5.15.2 (I believe Qt5.15.2 was installed by subversion).

*I would have expected pkg to prevent installing a mix of incompatible libraries.*

I confirm that running the following fixed my problem and am now able to launch the application


```
# pkg update -f
# pkg upgrade -f
```


----------



## zirias@ (Jul 9, 2022)

Emrion said:


> But what if you can't upgrade all your packages?


Then by all means, you should fix whatever is preventing you from doing so. Yes, your tip will still work as a *temporary(!)* workaround.


ahrkahrg said:


> Incompatibility between Qt5.15.5 and Qt5.15.2 (I believe Qt5.15.2 was installed by subversion).


Subversion doesn't depend on Qt, so I don't know how you got that idea


----------



## Emrion (Jul 9, 2022)

I can't even recall why I had a problem with xorg-server-1.20 nor with which of my FreeBSD machines. It was maybe related to evdev.

I think I was waiting for a new version of some packages. That said, don't worry, it was indeed temporary.


----------



## ahrkahrg (Jul 10, 2022)

Zirias said:


> Then by all means, you should fix whatever is preventing you from doing so. Yes, your tip will still work as a *temporary(!)* workaround.
> 
> Subversion doesn't depend on Qt, so I don't know how you got that idea


It is *after* installing subversion that the incompatibility arise. Not before. Note that installing subversion requested to load a lot of libraries.

It is not important if subversion uses qt or not (even indirectly), what is important is that the command line update and upgrade on pkg worked for me.


----------

