cxx-qt
cxx-qt copied to clipboard
qml_minimal example fails to bulid due to "byte index 1 is out of bounds of ``"
Hey there,
sorry if this is the wrong channel to ask questions. I was looking around for a Matrix/IRC/Discord channel in the documentation but couldn't find anything.
I'm new to both cxx-qt and qt development, so apologies also if this is an obvious problem :D
I'm trying to build the qml_minimal
example from the cxx-qt repository. I'm using a NixOS shell environment to install the build requirements into my environment (nix-shell -p rustc cargo qt5.full mold clang cmake
- it also happens with the qt6.full
package). I don't know if there's something missing from it though.
I try building the qml-minimal
example via this command:
cargo run -p qml-minimal-no-cmake
And here's the full stacktrace of my build (it looks like the cxx macro fails?): https://paste.rs/GBOwa.txt
Anyway, I hope you can give me some pointers as to what is wrong on my system/ what I'm missing to make this example build. Thanks in advance!
Thanks for taking to the time to report a bug, here is fine for questions we don't have any chat channels yet, or a discussion in github is fine for non-bugs :-)
This error does look curious, it seems to suggest that one of our .rs
files with CXX bridges is failing to be parsed by CXX / syn / somewhere else.
I assume that it is stopping on these block and not getting any futher? https://github.com/KDAB/cxx-qt/blob/386a7aaa2d24b68fd29b333b1357aed778e43089/crates/cxx-qt-lib/build.rs#L183-L184
Could you try commenting out some of the rust_bridges
(in the code block below), to see if it is one specific .rs
file that is causing an issue ?
Otherwise I can try to get a Nix environment setup to see if the issue is reproducible :-)
I also assume you are trying this from main
? Please also note that we are going through a slight API reshuffle so main
is halfway between what is documented in the book and what is in #555. Also note that main
has a regression for Qt 5 builds meaning that cargo-only builds will have issues with numbers in QML #592.
https://github.com/KDAB/cxx-qt/blob/386a7aaa2d24b68fd29b333b1357aed778e43089/crates/cxx-qt-lib/build.rs#L30-L175
Trying this out with Qt 6 i get a different error with Nix, due to the .prl
file missing / in a different place.
warning: Could not open /nix/store/5vn1qrh0dh60i3hnc87adsq5llxjxzyc-qtbase-6.5.1/lib/libQt6Qml.prl file to read libraries to link: No such file or directory (os error 2)
I can see the file here instead
[nix-shell:~/Projects/cxx-qt]# find /nix/store/ |grep -i libQt6Qml.prl
/nix/store/nflaf93xf4q0q6i7b3hay6nqk7b4ksp3-qtdeclarative-6.5.1/lib/libQt6Qml.prl
/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/lib/libQt6Qml.prl
[nix-shell:~/Projects/cxx-qt]# qmake -query
Detected locale "C" with character encoding "UTF-8", which is not UTF-8.
Qt depends on a UTF-8 locale, and has switched to "C.UTF-8" instead.
If this causes problems, reconfigure your locale. See the locale(1) manual
for more information.
QT_SYSROOT:
QT_INSTALL_PREFIX:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1
QT_INSTALL_ARCHDATA:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1
QT_INSTALL_DATA:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1
QT_INSTALL_DOCS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/doc
QT_INSTALL_HEADERS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/include
QT_INSTALL_LIBS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/lib
QT_INSTALL_LIBEXECS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/libexec
QT_INSTALL_BINS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/bin
QT_INSTALL_TESTS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/tests
QT_INSTALL_PLUGINS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/lib/qt-6/plugins
QT_INSTALL_QML:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/lib/qt-6/qml
QT_INSTALL_TRANSLATIONS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/translations
QT_INSTALL_CONFIGURATION:
QT_INSTALL_EXAMPLES:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/examples
QT_INSTALL_DEMOS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/examples
QT_HOST_PREFIX:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1
QT_HOST_DATA:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1
QT_HOST_BINS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/bin
QT_HOST_LIBEXECS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/libexec
QT_HOST_LIBS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/lib
QMAKE_SPEC:linux-g++
QMAKE_XSPEC:linux-g++
QMAKE_VERSION:3.1
QT_VERSION:6.5.1
@Be-ing Looks like another case for qt-build-utils
to cover?
@LeonMatthesKDAB also suffers from the missing prl file in Fedora but the build doesn't fail.
So I suspect my actual error here with Qt 6 is this one, failing to find qmltyperegistrar
(full error here https://paste.rs/Iq1Ce.txt )
--- stderr
thread 'main' panicked at 'Could not find qmltyperegistrar: ()', /var/home/andrew/Projects/cxx-qt/crates/qt-build-utils/src/lib.rs:508:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@ahayzen-kdab I get this error on Fedora as well:
warning: Could not open /usr/lib64/libQt6Qml.prl file to read libraries to link: No such file or directory (os error 2)
warning: Could not open /usr/lib64/libQt6Qml.prl file to read libraries to link: No such file or directory (os error 2)
Finished dev [unoptimized + debuginfo] target(s) in 1m 19s
But that doesn't cause any issues for me on Fedora 37. So I don't think this is the issue.
I'm getting another error though when trying to build in a nix docker container: https://paste.rs/rYfyU.txt So we clearly still have work to do with CXX-Qt in Nix :thinking:
@spacekookie did you experience any of these issues as well? Also, please let us know what version of cxx-qt you're building. 0.5? main?
So Qt 5 works under Nix for me (other than #593 ), i get the warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
warning many times and that's it.
And as a side note it does find the prl
files.
[nix-shell:~/Projects/cxx-qt]# find /nix/store/ |grep -i libQt6Qml.prl
/nix/store/nflaf93xf4q0q6i7b3hay6nqk7b4ksp3-qtdeclarative-6.5.1/lib/libQt6Qml.prl
/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/lib/libQt6Qml.prl
[nix-shell:~/Projects/cxx-qt]# qmake -query
QT_SYSROOT:
QT_INSTALL_PREFIX:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9
QT_INSTALL_ARCHDATA:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9
QT_INSTALL_DATA:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9
QT_INSTALL_DOCS:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9/share/doc/qt-5.15.9
QT_INSTALL_HEADERS:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9/include
QT_INSTALL_LIBS:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9/lib
QT_INSTALL_LIBEXECS:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9/libexec
QT_INSTALL_BINS:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9/bin
QT_INSTALL_TESTS:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9/tests
QT_INSTALL_PLUGINS:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9/lib/qt-5.15.9/plugins
QT_INSTALL_IMPORTS:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9/imports
QT_INSTALL_QML:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9/lib/qt-5.15.9/qml
QT_INSTALL_TRANSLATIONS:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9/translations
QT_INSTALL_CONFIGURATION:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9
QT_INSTALL_EXAMPLES:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9/examples
QT_INSTALL_DEMOS:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9/examples
QT_HOST_PREFIX:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9
QT_HOST_DATA:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9
QT_HOST_BINS:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9/bin
QT_HOST_LIBS:/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9/lib
QMAKE_SPEC:linux-g++
QMAKE_XSPEC:linux-g++
QMAKE_VERSION:3.1
QT_VERSION:5.15.9
[nix-shell:~/Projects/cxx-qt]# command -v qmltyperegistrar
/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9/bin/qmltyperegistrar
Then going back to Qt 6 with a clean build again, it does look like qmltyperegistrar
is the problem for me.
[nix-shell:~/Projects/cxx-qt]# command -v qmltyperegistrar
[nix-shell:~/Projects/cxx-qt]# find /nix -name qmltyperegistrar
/nix/store/nflaf93xf4q0q6i7b3hay6nqk7b4ksp3-qtdeclarative-6.5.1/libexec/qmltyperegistrar
/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/libexec/qmltyperegistrar
/nix/store/kkcf2gs5xqbirk55906zmly37pk29qwk-qtdeclarative-5.15.9-bin/bin/qmltyperegistrar
/nix/store/v25rhh4pgvwjspr3bax3kls0r97f16fi-qtdeclarative-5.15.9-dev/bin/qmltyperegistrar
/nix/store/4zmqkx9ws3vi40wc0fq6q1hrzvmwi0y3-qt-full-5.15.9/bin/qmltyperegistrar
[nix-shell:~/Projects/cxx-qt]# qmake -query
Detected locale "C" with character encoding "UTF-8", which is not UTF-8.
Qt depends on a UTF-8 locale, and has switched to "C.UTF-8" instead.
If this causes problems, reconfigure your locale. See the locale(1) manual
for more information.
QT_SYSROOT:
QT_INSTALL_PREFIX:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1
QT_INSTALL_ARCHDATA:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1
QT_INSTALL_DATA:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1
QT_INSTALL_DOCS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/doc
QT_INSTALL_HEADERS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/include
QT_INSTALL_LIBS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/lib
QT_INSTALL_LIBEXECS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/libexec
QT_INSTALL_BINS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/bin
QT_INSTALL_TESTS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/tests
QT_INSTALL_PLUGINS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/lib/qt-6/plugins
QT_INSTALL_QML:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/lib/qt-6/qml
QT_INSTALL_TRANSLATIONS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/translations
QT_INSTALL_CONFIGURATION:
QT_INSTALL_EXAMPLES:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/examples
QT_INSTALL_DEMOS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/examples
QT_HOST_PREFIX:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1
QT_HOST_DATA:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1
QT_HOST_BINS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/bin
QT_HOST_LIBEXECS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/libexec
QT_HOST_LIBS:/nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/lib
QMAKE_SPEC:linux-g++
QMAKE_XSPEC:linux-g++
QMAKE_VERSION:3.1
QT_VERSION:6.5.1
[nix-shell:~/Projects/cxx-qt]# ls -l /nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/libexec/qmltyperegistrar
lrwxrwxrwx 2 root root 88 Jan 1 1970 /nix/store/sy5dy9hqshc7smrq2q7cjnllsbkg1zla-qt-full-6.5.1/libexec/qmltyperegistrar -> /nix/store/nflaf93xf4q0q6i7b3hay6nqk7b4ksp3-qtdeclarative-6.5.1/libexec/qmltyperegistrar
So appears for me that qt-build-utils
needs to search QT_INSTALL_LIBEXECS
? cc @Be-ing
OK, so Qt 6 is now working by pointing to the right qmake executable. Appears that qmake6
gives incorrect values compared to qmake
under Qt 6 in a Nix environment. I'll create a patch to discuss the default, but you can always override with your own QMAKE
env var.
Note that qmake6
giving incorrect values in Qt 6 should be fixed via https://github.com/NixOS/nixpkgs/issues/239971, while waiting for this to flow to your nix channel you can set the env var QMAKE
to point to qmake
as a workaround.
Hey! Thanks for investigating this so quickly. I've not gotten any other errors, no. I've since tried using a more recent nixpkgs, with Qt6 (and setting QMAKE=qmake
) yields the same error. Here's a full build log, including which version hashes of dependencies I'm using: https://paste.rs/oQNHT.txt
I don't know if the build failures you've observed on Fedora are before or after the code is supposed to make it to that macro. I'm wondering if I'm missing some other dependency? If you want me to run any commands to test things in my environment, let me know (and apologies if you already have and I missed them in the comments)
The byte index 1 is out of bounds of
error is still odd, it looked like before it was coming from cxx/syn itself when parsing the rust files. I assume you haven't modified any of them or have any potential weird character encodings or something ? As when we tried a Nix env it didn't fail on that error for us but instead the qmake issues.
The failures we observed are after yours I believe, and once working around them we were able to have a successful build.
Hi, fancy seeing you here @spacekookie :)
Here's a full build log, including which version hashes of dependencies I'm using: https://paste.rs/oQNHT.txt
Could you rerun this with RUST_BACKTRACE=1
? Panicking in the Rust standard library is puzzling.