Skip to content

Cross-compiling Qt + Rust QML app for Windows in Docker fails with missing libpng symbols #1288

Open
@danields966

Description

@danields966

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 error

Repository: 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:

  1. 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?
  2. Any tips on how to structure the build.rs or Dockerfile to make this setup work?

Thanks for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 build systemIssues related to integrating CXX-Qt into CMake/Cargo🪲 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions