Hi, I am trying to share a bunch of shared types between crates in the same workspace. However, when running the build command it complains of two things:
If I add the include!("core/src/lib.rs.h") line in the "consumer" crate the build fails because the file does not exists. Which make sense, there is no file with such a name. I just tried this based on issue #1077 .
But if I don't put that line then the build process fails because of the following errors:
...
cargo:warning= | ^
cargo:warning=/home/hector/git/hectormrc/cxx-bridge/target/debug/build/consumer-86186167f538f322/out/cxxbridge/sources/consumer/src/lib.rs.cc:86:57: error: ‘::MySharedStruct’ has not been declared
cargo:warning= 86 | void cxxbridge1$do_another_thing(::MySharedStruct *t, ::MySharedStruct *return$) noexcept;
cargo:warning= | ^~~~~~~~~~~~~~
cargo:warning=/home/hector/git/hectormrc/cxx-bridge/target/debug/build/consumer-86186167f538f322/out/cxxbridge/sources/consumer/src/lib.rs.cc:86:73: error: ‘return$’ was not declared in this scope
cargo:warning= 86 | void cxxbridge1$do_another_thing(::MySharedStruct *t, ::MySharedStruct *return$) noexcept;
cargo:warning= | ^~~~~~~
cargo:warning=/home/hector/git/hectormrc/cxx-bridge/target/debug/build/consumer-86186167f538f322/out/cxxbridge/sources/consumer/src/lib.rs.cc:89:3: error: ‘MySharedStruct’ in namespace ‘::’ does not name a type
cargo:warning= 89 | ::MySharedStruct do_another_thing(::MySharedStruct t) noexcept {
cargo:warning= |
...
--- stderr
CXX include path:
/home/hector/git/hectormrc/cxx-bridge/target/debug/build/consumer-86186167f538f322/out/cxxbridge/include
/home/hector/git/hectormrc/cxx-bridge/target/debug/build/consumer-86186167f538f322/out/cxxbridge/crate
The full example can be found here: cxx bridge example
But in a nutshell my "core" crate is exposing a dummy type like this:
Finally, everything is meant to get build together using the following `build.rs` inside the consumer crate:
``` rust
// consumer/build.rs
fn main() {
cxx_build::bridge("src/lib.rs")
.std("c++11")
.compile("client");
}
What am I missing here? Using cxx_build::bridges the same thing happens. I also tried to generate first the headers files for the core crate, and then import them via include! to the consumer one, but it does not seams to find them out.
Hi, I am trying to share a bunch of shared types between crates in the same workspace. However, when running the
build
command it complains of two things:include!("core/src/lib.rs.h")
line in the "consumer" crate the build fails because the file does not exists. Which make sense, there is no file with such a name. I just tried this based on issue #1077 .But if I don't put that line then the build process fails because of the following errors:
The full example can be found here: cxx bridge example But in a nutshell my "core" crate is exposing a dummy type like this:
And the consumer is trying to use it like the following:
[cxx::bridge]
mod cxx_bridge { unsafe extern "C++" { // include!("core/src/lib.rs.h");
}
use core::cxx_bridge::MySharedStruct;
fn do_another_thing(t: MySharedStruct) -> MySharedStruct { cxx_bridge::do_something(t) }
What am I missing here? Using
cxx_build::bridges
the same thing happens. I also tried to generate first the headers files for the core crate, and then import them viainclude!
to the consumer one, but it does not seams to find them out.