KDAB / cxx-qt

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

Is there a way to integrate with other `cxx` libraries #568

Open OlivierLDff opened 1 year ago

OlivierLDff commented 1 year ago

Hi here is my setup.

This seem to be a known issue https://github.com/corrosion-rs/corrosion/issues/398.

Workaround I will go for know is to add more bindings to my first rust library, so I only have one library. And I will wrap the behavior I wanted to add to a qt object writing the QObject in c++, calling the rust binding.

My question is, is there another workaround that you are aware of? My first library only has 4 functions using cxx types (rust::Slices mostly and scalar). Would it be possible to just add those 4 functions binding inside a cxx-qt library?

ahayzen-kdab commented 1 year ago

This is also related to what CXX document in https://cxx.rs/build/other.html#linking-the-c-and-rust-together and https://doc.rust-lang.org/reference/linkage.html

Be-ing commented 1 year ago

There may be multiple complex issues here. First, regardless of cxx, Rust symbols need to be linked into every Rust library/executable, so you get duplicate symbol errors when trying to link multiple Rust staticlibs into one executable: #148. AFAIK the only workaround for this is to have one top level Rust staticlib crate with all the other Rust crates you're using as normal rlib dependencies.

Second, I don't know if cxxbridge and cxx-qt-build are compatible. This hasn't been tested.