dlopen failed: cannot locate symbol "__cxa_pure_virtual"
nikita-skobov opened this issue · 6 comments
This is a continuation of #14
I originally filed this same issue in cpal because I tried using cpal android example, as well as the oboe demo in this repository.
I even tried using the prebuilt oboe-demo in the releases (the latest one, 0.4.1), and i am still getting that error where the __cxa_pure_virtual is not found. More details here:
Should we give up linking with c++ stdlib by default?
Should we give up linking with c++ stdlib by default?
I think it is more appropriate to consider adding a c++ stdlib feature on the ndk side
@imxood Note that oboe
crate also may be used without ndk
crate, for example shared libs in Rust to use with jvm/flutter apps. Such use case was primary when I created this bindings.
Should we give up linking with c++ stdlib by default?
I think we have to make this by default. Because we also managed to run an android app only after linking to c++ stdlib.
It surprised me that the same build works on Android 10 but not on 11 & 12 (symbol __cxa_pure_virtual
not found).
Turning on the feature shared-stdcxx
works for me, while adding cargo:rustc-link-lib=c++_shared
failed with compile-time linking error (missing symbol __muloti4
).
oboe = { version = "0.5", features = ["shared-stdcxx"] }
I wrote the following Gradle script to copy libc++_shared.so
:
tasks.register("copyCppSharedLibrary") {
val src = android.ndkDirectory
.resolve("toolchains/llvm/prebuilt")
.listFiles()
.first { it.isDirectory }
.resolve("sysroot/usr/lib/aarch64-linux-android")
val dst = layout.buildDirectory.dir("rustJniLibs/android/arm64-v8a")
copy {
from(src)
into(dst)
include("libc++_shared.so")
}
}.configure {
dependsOn("cargoBuild")
}
Note that it only copy the aarch64 version.