Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Recommanded way to have multiple staticlib with corrosion #398

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

Recommanded way to have multiple staticlib with corrosion #398

OlivierLDff opened this issue May 31, 2023 · 2 comments

Comments

@OlivierLDff
Copy link
Contributor

I have 2 crate that depends on cxx, when I try to create a project that link to the 2 of them, I get linking error, as symbols for cxx object are defined more than once.

I've stumble across that: dtolnay/cxx#883

I'm unsure how to solve the problem in practice. I will investigate on my side, but has anyone sucessfully integrated 2 cxx crates using corrosion? Is there an example somewhere?

@jschwe
Copy link
Collaborator

jschwe commented May 31, 2023

It's not a cxx issue, it's a general rust issue: rust-lang/rust#104707

I've been thinking (but haven't had the time to implement) about adding an abstraction to Corrosion that does the following:

  • Create a dummy wrapper package that has a staticlib library target, and depends on all the libraries you need. This should be automatically created by a CMake function corrosion_create_wrapper_staticlib(new_lib_name dep_1_crate ...).
  • The dependencies would need to have an rlib target, so that cargo can link them into the wrapper crate.
  • corrosion currently ignores rlib only libraries, so potentially one would need to add a staticlib to import the actual cxx libraries, even if they will not be used directly, just to make corrosion aware that these libararies exist.

@OlivierLDff
Copy link
Contributor Author

OlivierLDff commented May 31, 2023

Ok, have you ever integrated 2 libraries yet with a workaround?
I guess I will go with the one crate with everything in it as it seems to be the faster solution now.

@corrosion-rs corrosion-rs locked and limited conversation to collaborators Jun 1, 2023
@jschwe jschwe converted this issue into discussion #401 Jun 1, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants