Hello people,
I am trying to call rust functions from cpp. I am using soong build system. I have a cpp file callToRust.cpp as follows:
extern "C"
{
int in_rust();
}
void foo()
{
int ret = in_rust();
}
and I am building it as a static library as follows:
In the Android.bp file:
cc_library_static{
name:"clibrary",
vendor_available:true,
srcs:["callToRust.cpp"],
shared_libs:[]
}
i have a rust file mylib.rs having the function:
#[no_mangle]
pub extern fn in_rust()->i32{
todo!()
}
I am building this file as a rust_ffi.
rust_ffi{
name:librust_fii_call,
vendor:true,
crate_name:rust_ffi_call,
srcs:["mylib.rs"],
},
building this way , gives the error as undefined symbol in_rust() in callToRust.cpp.
So , i added the rust_ffi library : "librust_fii_call" , in the shared_libs of the clibrary , but it also gives error as missing dependencies librust_fii_call.