Hi cxx-qt team, and thank you for building and maintaining this great toolkit!
I’m experimenting with cross-compiling a minimal Qt + Rust QML application for Windows (x86_64-pc-windows-gnu) inside Docker, using the basic example from this article as my starting point:
https://blog.logrocket.com/build-desktop-app-qt-rust/
The project structure and build.rs all work fine when targeting native Linux, but as soon as I switch to my Docker-based Windows build I hit linker errors related to PNG support. Here’s the relevant fragment of the output:
/usr/bin/x86_64-w64-mingw32-ld: …/libcxx_qt_lib-…/qpnghandler.o: undefined reference to `png_set_gAMA'
…/qpnghandler.o: undefined reference to `png_write_chunk'
…/qpnghandler.o: undefined reference to `png_set_PLTE'
…/qpnghandler.o: undefined reference to `png_destroy_write_struct'
collect2: error: ld returned 1 exit status
note: some extern functions couldn't be found; some native libraries may need to be installed or have their path specified
note: use the `-l` flag to specify native libraries to link
note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)
warning: Could not open /opt/qt5-static/lib/libQt5Network.prl … No such file or directory
warning: Could not open /opt/qt5-static/lib/libQt5Core.prl … No such file or directory
warning: Could not open /opt/qt5-static/lib/libQt5Gui.prl … No such file or directory
warning: Could not open /opt/qt5-static/lib/libQt5Qml.prl … No such file or directory
error: could not compile `rust_qt_qml_demo` (bin “rust_qt_qml_demo”) due to 1 previous errorRepository: https://github.com/danields966/rust_qt_qml_demo Dockerfile for Windows build: https://github.com/danields966/rust_qt_qml_demo/blob/main/Dockerfile-win64
Questions:
- Am I missing a flag or Build Script directive that automatically pulls in libpng (or the qimageformats plugin) and other dependencies for a static Windows build?
- Any tips on how to structure the build.rs or Dockerfile to make this setup work?
Thanks for your help!
Activity
2Otherwise it would be good to see does the same happen on a Windows VM / native machine, as it would be good to also fix the issues related to MinGW :-)
Thanks for the bug report, one thing to note in general is that we have no added MinGW yet as a tested platform. On Windows we currently only have MSVC2019 and MSVC2022 tested. So this issue might be related to MinGW itself rather than cross compiling. We would however like to add MinGW as a tested platform though to match Qt's supported platforms #645 .
I'm unsure if this is related to your issue, but it could be the cause of your issues, is it possible to try MSVC inside a docker container?