KDAB / cxx-qt

Safe interop between Rust and Qt
https://kdab.github.io/cxx-qt/book/
978 stars 67 forks source link

Documentation missing which runtime dependencies are required from a package manager #530

Open jimmyvanhest opened 1 year ago

jimmyvanhest commented 1 year ago

For linux there are 2 non obvious packages that are not documented that must be installed to run the examples. These packages are qml6-module-qtquick qml6-module-qtquick-templates.

When running the example without both of these packages, the error message was obvious for the first package.

QQmlApplicationEngine failed to load component
qrc:/main.qml:8:1: module "QtQuick" is not installed

After installing the qml6-module-qtquick package the error become somewhat confusing for v0.5.3.

QQmlApplicationEngine failed to load component
qrc:/main.qml:35:9: Type Label unavailable
qrc:/qt-project.org/imports/QtQuick/Controls/Fusion/Label.qml:38:1: static plugin for module "QtQuick.Templates" with name "com_kdab_cxx_qt_demo_plugin" has no metadata URI

I tought there might be a regression from earlier versions so I tried back to v0.4.1 and the error became more obvious.

QQmlApplicationEngine failed to load component
qrc:/main.qml:33:9: Type Label unavailable
qrc:/qt-project.org/imports/QtQuick/Controls/Fusion/Label.qml:38:1: module "QtQuick.Templates" plugin "qtquicktemplates2plugin" not found

After installing the qml6-module-qtquick-templates package the example for both v0.4.1 and v0.5.3 were running fine.

These dependencies should be mentioned somewhere, I think the readme, for reference. The other required packages wich I found in the .github/workflows/github-cxx-qt-tests.yml file, should also be mentioned at the same place.

ahayzen-kdab commented 1 year ago

Thanks for spotting this :-)

A lot of people use the Qt online installer which installs most the required packages.

This info could be added to the README and/or book, but then this is deb specific packages, eg rpm might use different names and macOS may be different again etc.

Maybe having a HACKING.md or README.developers.md file or something that is separate a lists all the dependencies for the different OSes would be a nice way of organising it and then link to this from the main README / book.

This separate file could then guide what you need to do when using either of the following

This would then be similar to hotspot's file https://github.com/KDAB/hotspot/blob/master/HACKING.md

ChrisCochrun commented 1 year ago

I'm having a very similar problem in Guix. It appears cxx-qt is looking for qqmlapplicationengine header for in Guix's qtbase package directory and Guix uses qtdeclarative for that file instead, but I can't seem to figure out how to tell cxx-qt-build to look there despite having the package installed.

ahayzen-kdab commented 1 year ago

@ChrisCochrun So qmake -query QT_INSTALL_HEADERS (or qmake6) is used to find the headers https://github.com/KDAB/cxx-qt/blob/b1f7da5e637985633591d08ac67f05c61175514e/crates/qt-build-utils/src/lib.rs#L378-L388 Maybe Guix is giving an incorrect value there ? We recently found that Nix's qmake6 was giving incorrect values (only giving qtbase not a folder that includes everything that qmake was).

I would be interested what your output of qmake -query and qmake6 -query are?

Otherwise you could manually include the relevant dirs with

CxxQtBuilder::new()
     ...
     .cc_builder(|cc| {
         cc.include("manual/path/to/include");
     })
     .build();

https://github.com/KDAB/cxx-qt/blob/b1f7da5e637985633591d08ac67f05c61175514e/crates/cxx-qt-build/src/lib.rs#L366-L384

ChrisCochrun commented 1 year ago

I would be interested what your output of qmake -query and qmake6 -query are?

Yes, I got: /gnu/store/mnpq5nyl81722hj2wpb7b9iikbndf9p5-qtbase-5.15.8/include/qt5

So that's the same as the nix situation. It's only getting the qtbase directory and not the other directories. Do i solve this in the same way you described at the last? Just place the correct directory in a cc_builder closure? Or did you guys have a solution for that Nix problem? Because Guix and Nix are extremely similar so I'd assume it could be addressed the same.

Be-ing commented 1 year ago

@ChrisCochrun if qmake doesn't point to where the headers actually are, that's a bug in the packaging.

ahayzen-kdab commented 1 year ago

Note this was the Nix bug we reported upstream, it's possible that Guix was inspired from the Nix packaging maybe so could be helpful in reporting a bug. https://github.com/NixOS/nixpkgs/issues/239971

@ChrisCochrun It would be useful if you could report a bug again Guix, otherwise one of us can try and reproduce and report one later...

ChrisCochrun commented 1 year ago

I'll submit a big report and see what I can find. Thanks for the directions. Didn't mean to hijack this thread, but thought it was relevant to figuring out dependencies on a more bespoke distro.

LeonMatthesKDAB commented 1 year ago

@ChrisCochrun if you have multiple versions of qmake (e.g. qmake6, qmake-qt5 are some common ones), you can check if one of them lists the right directories. If so, you can use the QMAKE environment variable to point Cxx-Qt to the right qmake, at least if you're building cargo-only.

ahayzen-kdab commented 1 year ago

@ChrisCochrun no problem, please link back to here or create a new issue to track it here if you do create an issue again Guix. So that we can get visibility on the issue as well and others can find it.