Hello! We are migrating our app from UE4 to UE5 for Android, and during this process, we’ve encountered a crash loop related to some third-party native libraries. These libraries were originally built and packaged in UE4 apk, where they worked as expected by dynamically linking against libc++_shared.so. In UE5, however, the same libraries now fail to load at runtime due to libc++_shared.so no longer being included in the packaged APK by default.
# Crash Log
java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found: needed by /lib/arm64/libfoobar.so in namespace classloader-namespaceThis issue did not occur in UE4, as the engine’s main libUE4.so had a dynamic dependency on libc++_shared.so, which was automatically included in the APK, making it also available for our native libraries. In UE5, libUnreal.so is now statically linked with libc++ (as per UE 5.3 release notes), and libc++_shared.so is no longer packaged by default, breaking the native libs dependencies that rely on it.
# Our Attempts & Results
- Statically link our own libraries with libc++
- Added -static-libstdc++ to the linker flags.
- This results in a different crash loop with FMallocBinned2 allocator errors:
Fatal error: [HAL/MallocBinned2.cpp] [Line: 918] FMallocBinned2 Attempt to realloc an unrecognized block+ Likely due to mismatched memory allocators between UE5 and statically linked libc++ code.
- Add RPATH to system libc++_shared.so path
- Used linker flags: -Wl,-rpath,/system/lib64 -Wl,-rpath-link,/system/lib64
- Verified via readelf that RPATH is set, but still get
dlopen failed: library "libc++_shared.so" not found# Temporary Workaround
By forcing the ANSI memory allocator in UE5 and statically linking libc++ in our third-party library builds, we were able to sideload an APK without crash.
# Questions
- Is there an officially supported way to integrate third-party dynamic libraries that require libc++_shared.so in UE5?
- Can we revert to dynamic libc++ linkage (as in UE4) via some configuration, or must all dependencies migrate to static linkage?
Thanks!
Chun