Qt: Difference between revisions

Sandro (talk | contribs)
Sandro (talk | contribs)
 
(One intermediate revision by the same user not shown)
Line 193: Line 193:
== Troubleshooting ==
== Troubleshooting ==


=== Cannot mix incompatible Qt library (version 0x_____) with this library (version 0x_____) ===
=== This application failed to start because it could not find or load the Qt platform plugin ??? in "" ===
 
This is a known issue, see {{issue|30551}} for the current status.
 
Starting with the 19.09 release, the issue should be fixed by {{pull|65526}}


=== This application failed to start because it could not find or load the Qt platform plugin ??? in "" ===
==== qt5 ====
{{warning|This recommendation is deprecated for 19.09 and up, see {{issue|65399}}. Failing packages should be updated to use <code>wrapQtAppsHook</code>.}}
{{warning|This recommendation is deprecated for 19.09 and up, see {{issue|65399}}. Failing packages should be updated to use <code>wrapQtAppsHook</code>.}}
Qt5 seems (?) to look for plugins in the <code>PATH</code>. This will fail from a systemd user unit for example, because their path is nearly empty by default. As an example, here is a workaround to have <code>usbguard-applet</code> launched from a systemd user unit:
{{File|/etc/nixos/configuration.nix|nix|<nowiki>
  systemd.user.services.usbguard-applet = {
    description = "USBGuard applet";
    partOf = [ "graphical-session.target" ];
    wantedBy = [ "graphical-session.target" ];
    path = [ "/run/current-system/sw/" ]; ### Fix empty PATH to find qt plugins
    serviceConfig = {
      ExecStart = "${pkgs.usbguard}/bin/usbguard-applet-qt";
    };
  };
</nowiki>}}
====  qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in "" ====
Here is a concrete example:


<pre>
<pre>
Line 226: Line 204:
The package will need to be fixed to use [the new https://github.com/NixOS/nixpkgs/issues/65399 <code>wrapQtAppsHook</code>]. The hook wraps every qt application with adding <code>QT_PLUGIN_PATH</code> and <code>XDG_DATA_DIRS</code> as well as <code>XDG_CONFIG_DIRS</code>.See [https://github.com/NixOS/nixpkgs/blob/nixos-19.09/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh wrap-qt-apps-hook.sh in nixpkgs]
The package will need to be fixed to use [the new https://github.com/NixOS/nixpkgs/issues/65399 <code>wrapQtAppsHook</code>]. The hook wraps every qt application with adding <code>QT_PLUGIN_PATH</code> and <code>XDG_DATA_DIRS</code> as well as <code>XDG_CONFIG_DIRS</code>.See [https://github.com/NixOS/nixpkgs/blob/nixos-19.09/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh wrap-qt-apps-hook.sh in nixpkgs]


==== Debugging methods ====
=== Debugging methods ===
As a general rule, exporting <code>QT_DEBUG_PLUGINS=1</code> make qt print where it looks for plugins.
As a general rule, exporting <code>QT_DEBUG_PLUGINS=1</code> make qt print where it looks for plugins.


If a plugin exists in a directory but is ignored with a message like <code>QLibraryPrivate::loadPlugin failed on "/nix/store/...-teamspeak-client-3.1.6/lib/teamspeak/platforms/libqxcb.so" : "Cannot load library /nix/store/...-client-3.1.6/lib/teamspeak/platforms/libqxcb.so: "</code> it can be that the library cannot be <code>dlopen()</code>ed because of dependencies/rpath issues and needs <code>patchelf</code>ing. Exporting <code>LD_DEBUG=libs</code> may prove helpful in this scenario.
If a plugin exists in a directory but is ignored with a message like <code>QLibraryPrivate::loadPlugin failed on "/nix/store/...-teamspeak-client-3.1.6/lib/teamspeak/platforms/libqxcb.so" : "Cannot load library /nix/store/...-client-3.1.6/lib/teamspeak/platforms/libqxcb.so: "</code> it can be that the library cannot be <code>dlopen()</code>ed because of dependencies/rpath issues and needs <code>patchelf</code>ing. Exporting <code>LD_DEBUG=libs</code> may prove helpful in this scenario.