Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guessed qt_prfxpath wrong (Qt 5 gets deployed instead of Qt 6) #268

Open
VioletGiraffe opened this issue Nov 16, 2023 · 12 comments
Open

Guessed qt_prfxpath wrong (Qt 5 gets deployed instead of Qt 6) #268

VioletGiraffe opened this issue Nov 16, 2023 · 12 comments
Labels
bug Something isn't working

Comments

@VioletGiraffe
Copy link

VioletGiraffe commented Nov 16, 2023

The problem is well illustrated by this log. Qt 6 dependency is detected (correctly), but Qt 5 is deployed. Looks like it could be because Qt 5 was the first folder where it found libqxcb.so?..

2023/11/16 23:34:41 Detected Qt 6
2023/11/16 23:34:41 Offset of qt_prfxpath: 3522924
2023/11/16 23:34:41 Length of value of qt_prfxpath: 4
2023/11/16 23:34:41 qt_prfxpath: /usr
2023/11/16 23:34:41 Got qt_prfxpath but it does not contain 'plugins'
2023/11/16 23:35:28 libqxcb.so found: [/usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libqxcb.so /usr/lib/aarch64-linux-gnu/qt6/plugins/platforms/libqxcb.so]
2023/11/16 23:35:28 Guessed qt_prfxpath to be /usr/lib/aarch64-linux-gnu/qt5
2023/11/16 23:35:28 Looking in /usr/lib/aarch64-linux-gnu/qt5/plugins
@probonopd
Copy link
Owner

probonopd commented Nov 16, 2023

Guessed qt_prfxpath to be /usr/lib/aarch64-linux-gnu/qt5

This is the issue. It is wrong (assumig you want Qt6). We need to fx it. Volunteers?

This whole guessing is not reliable. What would be a more robust way to know which Qt to use, and from where?

@probonopd probonopd added the bug Something isn't working label Nov 16, 2023
@VioletGiraffe
Copy link
Author

VioletGiraffe commented Nov 16, 2023

That is a good question, I navigated the Qt folders a bit and it all looks like a bunch of mess. But it does work. How do the Qt .so libraries know where to look for plugins? They're not in the same parent folders as is the case on Windows.

>  qmake -v
Using Qt version 6.4.2 in /usr/lib/aarch64-linux-gnu
> ldd bin/myapp
libQt6Gui.so.6 => /lib/aarch64-linux-gnu/libQt6Gui.so.6 (0x0000007fa97a0000)
libQt6Core.so.6 => /lib/aarch64-linux-gnu/libQt6Core.so.6 (0x0000007fa92b0000)

So the question is, as far as I understand, how to locate the plugins. They're not in /usr/lib/aarch64-linux-gnu/ but instead in /usr/lib/aarch64-linux-gnu/qt6/.

@probonopd
Copy link
Owner

probonopd commented Nov 16, 2023

How do the Qt .so libraries know where to look for plugins?

The string qt_prfxpath is hardcoded in one of the Qt .so libraries. It's pretty much under-documented, though.

And sometimes, it's even outright wrong.

@VioletGiraffe
Copy link
Author

VioletGiraffe commented Nov 16, 2023

Okay, judging from the appimagetools log the string says just /usr, that's wrong as there are no plugins there. But somehow Qt works fine.

@probonopd
Copy link
Owner

Black magic!

@probonopd
Copy link
Owner

So the question is, as far as I understand, how to locate the plugins. They're not in /usr/lib/aarch64-linux-gnu/ but instead in /usr/lib/aarch64-linux-gnu/qt6/.

... but currently go-appimage (wrongly)

Guessed qt_prfxpath to be /usr/lib/aarch64-linux-gnu/qt5

@probonopd
Copy link
Owner

All I can tell you at the moment is that the bug is somewhere in

// Special case:
// Some distributions, including Ubuntu and Alpine,
// have qt_prfxpath set to '/usr' but the files are actually in e.g., '/usr/lib/qt5'
// In this case, we should NOT patch it
if helpers.IsDirectory(qt_prfxpath+"/plugins") == false {
log.Println("Got qt_prfxpath but it does not contain 'plugins'")
results := helpers.FilesWithSuffixInDirectoryRecursive(qt_prfxpath, "libqxcb.so")
log.Println("libqxcb.so found:", results)
if len(results) > 0 {
result := results[0]
qt_prfxpath = filepath.Dir(filepath.Dir(filepath.Dir(result)))
log.Println("Guessed qt_prfxpath to be", qt_prfxpath)
quirksModePatchQtPrfxPath = true
} else {
log.Println("ERROR: Could not determine the path to Qt automatically")
log.Println("Please set $QTDIR to the path to Qt (the directory that contains plugins/, qml/, etc.)")
log.Println("and try again")
os.Exit(1)
}
}

@probonopd
Copy link
Owner

In the meantime, try export QTDIR=/usr/lib/aarch64-linux-gnu/qt6/ before running linuxdeployqt. Do this on a new AppDir (one which linuxdeployqt was never run on before).

@VioletGiraffe
Copy link
Author

VioletGiraffe commented Nov 16, 2023

As for the code: you take the 1st result which happened to be qt5 (or it will always be qt5 based on alphabetical sorting), instead you should check whether it's Qt5 or 6 - you already know that Qt 6 is required.
I'm not a fan of writing even more complex fragile heuristics, but in this case seems inevitable as the current solution simply doesn't support Qt 6 .

Upd: or you can remove the guessing altogether and require QTDIR to be defined if qt_prfxpath does not contain "plugins".

@VioletGiraffe
Copy link
Author

In the meantime, try export QTDIR=/usr/lib/aarch64-linux-gnu/qt6/ before running linuxdeployqt.

That worked! The correct paths are in the log now, and the AppImage size is reduced. However, it still doesn't run:

Failed to load the image at
Press any key to exit.

Any ideas? What can I do to troubleshoot this?

@probonopd
Copy link
Owner

Is that message coming from your program?

@VioletGiraffe
Copy link
Author

You're right, sincere apologies. I was so puzzled by the message that I was certain it's from the AppImage runtime.
And many thanks for your help!

@probonopd probonopd changed the title Qt 6 dependency is detected, but Qt 5 gets deployed Guessed qt_prfxpath wrong (Qt 5 gets deployed instead of Qt 6) Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants