-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
android example crashes on launch: "dlopen failed: cannot locate symbol __cxa_pure_virtual" #563
Comments
@nikita-skobov I've also run into this issue, also on a Pixel 4a. I also tried a bunch of different things over a couple of days (including manually linking the missing C++ runtime symbols from In the end I've chosen to use AAudio directly instead of using cpal+Oboe when building for Android. |
Could you refer me to a minimal example? I tried AAudio as well but I've must have done it wrong because I couldn't get it to work. |
I can't point you to an example as I'm working on a private project, but I can say that I found it quite straight-forward using @endragor's AAudio bindings.
let buffer = unsafe {
std::slice::from_raw_parts_mut(
buffer.as_ptr() as *mut f32,
frames as usize * CHANNEL_COUNT,
)
};
This is my first time looking at AAudio so I might have misunderstood something here, but it seems to be working pretty well so far. |
Hi, I saw this same error when using jni-rs (so nothing to do with cpal, sorry, I found this issue through google). In my lib.rs I had some JNI method implementations (e.g. I found that when I deleted my C functions from lib.rs (I didn't need them anyway, just a relic from some testing I was doing) this error went away. FWIW my rust library depends on oboe-rs, so I'm in the same ballpark as you two. I'm not using CPAL because I only found out about it today. Edit: scratch that, it's started showing this error again and I've just added more JNI functions... Edit edit: it looks like the C functions were a red herring. When I switched between building with debug to building with release mode, it seemed to resolve the issue. I must have tried two things at once - not very scientific of me. Edit edit edit: I'm not even sure it's release mode as it seems to come and go completely randomly. It might be going wrong when I build with this plugin but not when I build via command line, but I'm not 100% sure. Last edit: seems just random whether it decides to fail. I can make any change to the code and next time it might work or might fail. |
This can be solved by enabling the shared-stdcxx feature for oboe
Then I also had to copy libc++_shared.so into my jniLibs directory (there's likely a way to automate this...) |
My device:
Steps to reproduce:
First I tried:
Then I install the android.apk to my phone, and run it, and it crashes immediately. Looking at the logcat:
Click to expand
I looked up the issue with
__cxz_pure_virtual
and some people said you could just stub it out with:So I tried putting that in
examples/android.rs
and rebuilding, and then I get:With the __cxa_pure_virtual stub
Click to expand
So a similar error, but this time it cant find some other function.
I also found @katyo oboe-rs project, and I see they have oboe-demo.apk in their releases, so I thought I should try running an apk that someone else built (maybe my error was coming from me building it wrong somehow), so I ran that oboe-demo.apk and this time I see:
From the oboe-demo example
Click to expand
So in the oboe-demo, it actually didnt 'crash' right away. it kept running, but it wasnt doing anything. it was just producing this error over and over, and once again the issue is
dlopen failed: cannot locate symbol "__cxa_pure_virtual"
Conclusion
Is this an issue with android 11 not having stdc++ or something like that? i think i saw someone comment something like that before.
I debugged this for a few hours today and tried a bunch of different forks and hacks and I couldn't figure it out, so hoping someone with more knowledge about android audio could help me out.
The text was updated successfully, but these errors were encountered: