You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my C++ project I have two rust crates that export a C++ API using cxx.
That setup ends in a bunch of linking errors like this:
/usr/bin/ld: libangelfish_readability.a(cxx-546393ec83734d88.cxx.77528ncj-cgu.12.rcgu.o): in function `cxxbridge1$exception':
/home/jbb/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/cxx-1.0.49/src/symbols/exception.rs:6: multiple definition of `cxxbridge1$exception'; libangelfish_adblock.a(cxx-506fb85a29953a06.cxx.6ziszbha-cgu.12.rcgu.o):/home/jbb/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/cxx-1.0.49/src/symbols/exception.rs:6: first defined here
/usr/bin/ld: libangelfish_readability.a(cxx-546393ec83734d88.cxx.77528ncj-cgu.12.rcgu.o): in function `cxxbridge1$str$from':
/home/jbb/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/cxx-1.0.49/src/symbols/rust_str.rs:18: multiple definition of `cxxbridge1$str$from'; libangelfish_adblock.a(cxx-506fb85a29953a06.cxx.6ziszbha-cgu.12.rcgu.o):/home/jbb/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/cxx-1.0.49/src/symbols/rust_str.rs:18: first defined here
Can I do anything about it apart from moving everything into one crate, or is this a general limitation?
The text was updated successfully, but these errors were encountered:
you first need to use rustc and/or cargo to generate a single Rust staticlib target and pass that into your foreign linker invocation.
If you need to link multiple Rust subsystems, you will need to generate a singlestaticlib perhaps using lots of extern crate statements to include multiple Rust rlibs. Multiple Rust staticlib files are likely to conflict.
That all seems consistent with what you've described. Rust does not expose any way for a C++ linker to link multiple Rust staticlibs. That part always has to be done by Rust's linker.
In my C++ project I have two rust crates that export a C++ API using cxx.
That setup ends in a bunch of linking errors like this:
Can I do anything about it apart from moving everything into one crate, or is this a general limitation?
The text was updated successfully, but these errors were encountered: