-
Notifications
You must be signed in to change notification settings - Fork 362
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
Using many cxx libraries at the same time #252
Comments
I thought a bit more about this, and to me, it looks like these are symbols defined in rust, not in the cpp file, so just not building against the cxx cpp file probably won't help in this case Edit: I was going to try to add a fix for this, so I added cxx as a submodule and now things compile as expected. I pressume that's not a solution though |
Mozilla's approach to the duplicate symbols problem is to compile all libraries into rlibs, and then create a single wrapper crate around all of them that compiles into a staticlib for linking purposes. I'm curious to see if that could be applicable for |
I wrote some stuff here which may be relevant: but the bottom line is, @antonok-edm is right - the only realistic solution is to pull all your Rust code together into a single |
When you have multiple disparate Rust libraries that you link into a larger C/C++ executable, you need to create a super crate that links all dependencies to avoid linkage issues (e.g. so that Cargo & Rust can see semver incompatabilities & build them correctly among other things). Add `rlib` to the `crate-type` list for C bindings to allow building such a "super" crate. The following links: * https://github.com/adetaylor/cxx/blob/book/book/src/building.md#linking-the-c-and-rust-together * dtolnay/cxx#252 have more context.
When you have multiple disparate Rust libraries that you link into a larger C/C++ executable, you need to create a super crate that links all dependencies to avoid linkage issues (e.g. so that Cargo & Rust can see semver incompatabilities & build them correctly among other things). Add `rlib` to the `crate-type` list for C bindings to allow building such a "super" crate. The following links: * https://github.com/adetaylor/cxx/blob/book/book/src/building.md#linking-the-c-and-rust-together * dtolnay/cxx#252 have more context.
When you have multiple disparate Rust libraries that you link into a larger C/C++ executable, you need to create a super crate that links all dependencies to avoid linkage issues (e.g. so that Cargo & Rust can see semver incompatabilities & build them correctly among other things). Add `rlib` to the `crate-type` list for C bindings to allow building such a "super" crate. The following links: * https://github.com/adetaylor/cxx/blob/book/book/src/building.md#linking-the-c-and-rust-together * dtolnay/cxx#252 have more context.
Since I liked the first time I used this crate, I figured I could start RIIRing another part of my project. This part is a standalone library, so I don't want to merge it with my first converted part, but unfortunately that means I run into some linker errors because I now link against the cxx library twice.
Is there a way to work around this, something like optionally not building against the cxx cpp file?
The text was updated successfully, but these errors were encountered: