sonos / dinghy

Easier cross-compilation for phones and single boards computers
Other
365 stars 44 forks source link

`undefined symbol: ANativeWindow_setBuffersGeometry` with visual tests using `wgpu` #198

Closed torokati44 closed 12 months ago

torokati44 commented 1 year ago

When trying to run the visual tests of Ruffle (using wgpu) on Android, I'm getting a linker error: = note: ld.lld: error: undefined symbol: ANativeWindow_setBuffersGeometry. This is basically the same as: https://github.com/xamarin/xamarin-android/issues/6765

I was able to get around it by setting RUSTFLAGS="-C link-args=-L$HOME/Android/Sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/29/ -C link-args=-lnativewindow"

Is there an easier way to fix this, perhaps a solution that would deal with this automatically...?

fredszaq commented 1 year ago

Hi @torokati44 I get quite a few errors when running a cargo dinghy -d android test in https://github.com/ruffle-rs/ruffle root dir... but I don't even get to linking.... what command are you using ?

From the workaround you have :

torokati44 commented 1 year ago

Right, sorry, the command I ran was: RUSTFLAGS="-C link-args=-L$HOME/Android/Sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/29/ -C link-args=-lnativewindow" cargo dinghy -d android --platform "auto-android-aarch64" test --package tests --features imgtests

The --platform "auto-android-aarch64 part might not have been necessary... The --package tests --features imgtests part is important, because we have desktop- and web-specific tests that definitely won't work; and visual tests are not enabled by default.

Yeah the first thing I tried was exactly that line in build.rs, but for some reason it wasn't enough - perhaps only because then I haven't added the -L flag yet.

And yes, I too have expected the -L flag to not be necessary, but alas, the library was not found without it. I don't know why.

fredszaq commented 12 months ago

Hi @torokati44 !

I had a chance to give it another look today, and in fact one of the problems is that dinghy is by default using api level 21 if you don't tell it which one to use. libnativewindow is only available starting api 29 from what I see in the ndk.

try passing --platform "auto-android-aarch64-api29" instead of --platform "auto-android-aarch64" and you won't have to pass the -L anymore

I stand by the fact that the -lnativewindow should be passed in the build.rs of the crate that is using the apis in this lib

torokati44 commented 12 months ago

I had a chance to give it another look today, and in fact one of the problems is that dinghy is by default using api level 21 if you don't tell it which one to use. libnativewindow is only available starting api 29 from what I see in the ndk.

Ah, I see...

try passing --platform "auto-android-aarch64-api29" instead of --platform "auto-android-aarch64" and you won't have to pass the -L anymore

Indeed, thank you!

I stand by the fact that the -lnativewindow should be passed in the build.rs of the crate that is using the apis in this lib

Yeah, that makes sense.