bkaradzic / bgfx

Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.

Home Page:https://bkaradzic.github.io/bgfx/overview.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Small fix on soname defining on ldflags for Android examples.

gsfare opened this issue · comments

This bug is similar to that which was fixed in this report,

#2176

Essentially it's regarding how the examples are built for Android and how to link them into an Android application. It can't be guaranteed which version of the Android NDK is being used and the SONAME should be defined in any d=shard library built for Android otherwise the runtime linker (using dlopen) will use the default path which is generally based upon the host cross-compile filesystem.

Here is a repo that reproduces the issue, it results in a linker error at runtime when the app is run on a Android device.

https://github.com/gsfare/bgfx-android-examples/tree/main

The error is below since the dynamic linker is trying to find the path for the library on the host machine rather than the device it's running on.

10-16 14:47:54.295 5043 5043 E AndroidRuntime: java.lang.UnsatisfiedLinkError: Unable to load native library "/data/app/~~i4NjwSJJQf-gkES-Ln5HAQ==/com.example.native_activity-1ubDSe4RYAA71-UBJ5O5iQ==/lib/arm64/libnative-activity.so": dlopen failed: library "/home/garethf/Development/bgfx-android-examples/native-activity/app/src/main/cpp/../../../../../bgfx/.build/android-arm64/bin/libexamplesRelease.so" not found: needed by /data/app/~~i4NjwSJJQf-gkES-Ln5HAQ==/com.example.native_activity-1ubDSe4RYAA71-UBJ5O5iQ==/lib/arm64/libnative-activity.so in namespace clns-4
I have a fix for this already, I just wanted to raise a ticket so it can be tracked/commented/discussed appropriately! I'll post a PR for this issue for review.

Sure, send fix PR.

Here is the PR. Happy to change if needed. Just let me know.

#3184