Linking rust ffi library to cc_library_static

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:


i have a rust file having the function:

 pub extern fn in_rust()->i32{

I am building this file as a rust_ffi.


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.

That's only a declaration, not a definition. It looks like you never actually implemented the Rust function.

By the way, your code is full of syntax errors and is very hard to read in the absence of proper formatting. If you want to get useful advice, help those trying to help you. Dumping a wall of unformatted code does not make a great question.

sorry for the confusion, i made the required changes please have a look at it.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.