How can I solve "Unable to load native library ... dlopen failed: cannot locate symbol "ffi_type_void" referenced by ..."

I am working on an android VR app that works with cargo apk run.
I have completed an earlier app that can draw objects (suzanne and a color triangle) in VR.
I am moving to the next step where I want to use gstreamer to provide video for a texture, but if I call gst::init() in my code, I get this error at run time:

2023-06-28 10:47:25.869 24722-24722/rust.openxr_gst D/AndroidRuntime: Shutting down VM
2023-06-28 10:47:25.873 24722-24722/rust.openxr_gst E/AndroidRuntime: FATAL EXCEPTION: main
    Process: rust.openxr_gst, PID: 24722
    java.lang.UnsatisfiedLinkError: Unable to load native library "/data/app/~~FA8MGKpl2mLhXMiDdEkMWw==/rust.openxr_gst-KtRUUHinSBxQJoTnbLGurA==/lib/arm64/": dlopen failed: cannot locate symbol "ffi_type_void" referenced by "/data/app/~~FA8MGKpl2mLhXMiDdEkMWw==/rust.openxr_gst-KtRUUHinSBxQJoTnbLGurA==/lib/arm64/"...

calling gst::init() causes my app to refer to several undefined symbols in the .so

$ nm ./target/aarch64-linux-android/debug/*.so | grep ffi_type
                 U ffi_type_double
                 U ffi_type_float
                 U ffi_type_pointer
                 U ffi_type_sint32
                 U ffi_type_sint64
                 U ffi_type_uint32
                 U ffi_type_uint64
                 U ffi_type_void
000000000038535c t value_from_ffi_type
000000000038515c t value_to_ffi_type

How can I figure out which crate is depending on these, and then figure out how to link in the proper library to satisfy those symbols?

Those symbols are from libffi, a widely-used JITed C interop library. It looks like your library is dynamically linked to libffi. You may want to find the appropriate and copy it over next to your library. (If this is a cross-compile, you should install it on your target system instead.)

One of my coworkers was able to find another project that uses libffi and suggested I add -lffi to my RUSTFLAGS, which got me to the next explosion (which is unrelated).

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.