Protobuf version conflicts with Qt

As Blabdouze said, this error is caused by the libqgtk3 plugin which is used to set the GUI style. libqgtk3 uses the libmir system library, which uses protobuf 2.6.1. This leads to conflicts when the application starts.

I found a workaround that allows you to avoid editing of Qt files:

  1. You need to copy the "plugins" folder from ".../Qt/5.хх.хх/gcc_64/" to some other location (for example, next to the project build folder).
  2. Then you must remove "platformthemes/libqgtk3.so" and "platformthemes/libqgtk3.so.debug" from the copied folder.
  3. In main(), before creating a QApplication instance, call the static function "QApplication::setLibraryPaths("path/to/copied/plugins/folder")".
  4. Finally, you must add variable "LD_LIBRARY_PATH" with the value ".../Qt/5.хх.хх/gcc_64/lib" (correct path will depend on your Qt version) in a project's "environment settings" in Qt Creator. You also may add a "QT_DEBUG_PLUGINS" variable with a value of "1". It will allow you to check which plugins are used by your project and remove unnecessary plugins from the release version.

In conclusion I would like to note that this error occurred when running the project in Ubuntu 16.04, but it disappeared when I switched to version 18.04. It seems that in version 18.04 app uses the default Qt style instead of the GTK style.


You can find here a discussion about the same issue and they talk about an interesting workaround.

It seems that this error is caused by the library libqgtk3.so located in /opt/Qt/5.9/gcc_64/plugins/platformthemes. If you don't need it in your project you can rename/remove it to make the error go away.

If you are using CMake as a build system you also need to comment all the lines in the file /opt/Qt/5.9/gcc_64/lib/cmake/Qt5Gui/Qt5Gui_QGtk3ThemePlugin.cmake to avoid configure issues.

To add on, the real problem comes from the library libmir which depends on the the libprotobuf. You may run on this problem whenever you try to use recent tensorflow with libgtk3.0 because of this hard dependency. As libmir depends on the system libprotobuf which is normally behind the version in use by tensorflow (which downloads its own version from the repository).

The good news, this BUG on libgtk was reported and fixed however, to use the fixed version you have to move to libgtk3.0 3.22 (see BUG report).


If you are using Qt from the Ubuntu package repository, you can remove the offending library by uninstalling qt5-gtk-platformtheme. This will remove libqgtk3.so and the corresponding CMake file without having to resort to hacks that might have unintended consequences.