Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
OlivierLDff opened this issue May 31, 2023 · 2 comments
Open

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

OlivierLDff opened this issue May 31, 2023 · 2 comments

Comments

@OlivierLDff
Copy link
Contributor

Hi here is my setup.

  • I have a rust library that I exposed to to c++ with cxx and corrosion_add_cxxbridge. That is used in a non Qt related part of the application.
  • I want to create a qobject in c++ using cxx-qt. So I follow the book tutorial, and I get linker error due to duplicate symbols of some cxx types (Slices, Str, etc...).

This seem to be a known issue corrosion-rs/corrosion#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?

@OlivierLDff OlivierLDff changed the title Is there a way to integrate with other cxx binding library Is there a way to integrate with other cxx libraries May 31, 2023
@ahayzen-kdab
Copy link
Collaborator

@Be-ing
Copy link
Contributor

Be-ing commented May 31, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants