Closed akiselev closed 1 month ago
After instrumenting cxx-qt-build
it looks like it's generating all of the #[cxx_qt::bridge]
code in the same ffi.cxx.cpp
file path, where as cxx-qt-lib
files annotated with #[cxx::bridge]
have unique names.
warning: linker-repro@0.1.0: Generating "/home/akiselev/git/linker-repro/target/debug/build/linker-repro-ed6c7f718c01b592/out/cxx-qt-gen/src/ffi.cxx.cpp"
warning: linker-repro@0.1.0: Generating "/home/akiselev/git/linker-repro/target/debug/build/linker-repro-ed6c7f718c01b592/out/cxx-qt-gen/src/ffi.cxx.cpp"
warning: cxx-qt-lib@0.6.1: Generating "/home/akiselev/git/linker-repro/target/debug/build/cxx-qt-lib-22d15c8779448e22/out/cxx-qt-gen/src/qbytearray.cxx.cpp"
warning: cxx-qt-lib@0.6.1: Generating "/home/akiselev/git/linker-repro/target/debug/build/cxx-qt-lib-22d15c8779448e22/out/cxx-qt-gen/src/qcoreapplication.cxx.cpp"
Is this intentional behavior with cxx-qt? Is there a way I can fix it to generate separate files?
Since the file is named after the module (ffi
in both files in this case), it overwrote them. Turns out I have to have unique module names for the CxxQtBridge.
Yup, until https://github.com/rust-lang/rust/issues/54725 is stabilised we cannot replicate the CXX behaviour, see the ancient WIP branch here https://github.com/KDAB/cxx-qt/pull/200 and issue here https://github.com/KDAB/cxx-qt/issues/855
Until that happens I was going to make cxx_file_stem
mandatory to avoid this situation, one of the commits in https://github.com/KDAB/cxx-qt/pull/856
Repro repository here: https://github.com/akiselev/linker-repro
I am trying to bind several QWidgets classes but I'm getting undefined reference/symbol errors when trying to build more than one Rust file with CxxQt bindings.
For the above repro repository, this is the order in
build.rs
This is the error (I have tried with lld and mold):
If I change the order of the
builder.file
calls inbuild.rs
:It finds the QMainWindow symbols but instead fails to find the QWindow symbols:
Whichever Rust file is last is the one that gets linked in, the rest get ignored. If I use this order in build.rs:
and remove QMainWindow from main.rs altogether:
It builds and shows a window when run.
Does anyone have any idea why this is happening?