google / google/filament

android: Linking against filament fails (using NDK v25)

Open
#7,931 0 comments 0 reactions 1 assignee Claimed by @pixelflinger View on GitHub
android build
Dominant language
C++
Stars
20.5k
Forks
2.3k
Avg merge
2d 14h
Merged PRs (30d)
83

Description

⚠️ **Issues not using this template will be systematically closed.**

**Describe the bug**

In our android project we build filament from source and link it in our android project (so that we can use filament from c++ as well).
Our project uses NDK v25. Filament was recently [upgraded to use NDK v27](https://github.com/google/filament/pull/7902). When now linking against filament we get the following build errors (see logs):

```
ld: error: undefined symbol: std::__ndk1::__libcpp_verbose_abort(char const*, ...)
>>> referenced by BufferInterfaceBlock.cpp
>>> BufferInterfaceBlock.cpp.o:(std::__ndk1::__throw_length_error[abi:nn180000](char const*)) in archive ../../../../libs/filament/lib/arm64-v8a/libfilabridge.a
```

**To Reproduce**
Steps to reproduce the behavior:
1. Create a new android app
2. Build filament from source
3. Include the filament library + headers in your CMakeList file
4. Use NSDK v25

**Expected behavior**
A clear and concise description of what you expected to happen.

It builds and is compatible with NDK v25.

**Screenshots**

n/a

**Logs**

```
[58/58] Linking CXX shared library ../../../../build/intermediates/cxx/Debug/395m3w6x/obj/arm64-v8a/libreact-native-filament.so
FAILED: ../../../../build/intermediates/cxx/Debug/395m3w6x/obj/arm64-v8a/libreact-native-filament.so
: && /Users/hannomargelo/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android23 --sysroot=/Users/hannomargelo/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -O2 -frtti -fexceptions -Wall -Wno-unused-variable -fstack-protector-all -fno-limit-debug-info -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libreact-native-filament.so -o ../../../../build/intermediates/cxx/Debug/395m3w6x/obj/arm64-v8a/libreact-native-filament.so CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/RNFFilamentView.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/RNFFilamentProxy.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/RNFFilamentRecorder.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/RNFSurface.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/RNFSurfaceProvider.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/RNFChoreographer.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/RNFChoreographerWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/RNFListener.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/jsi/RNFHybridObject.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/jsi/RNFPromise.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/jsi/RNFPromiseFactory.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/jsi/RNFRuntimeCache.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/jsi/RNFWorkletRuntimeRegistry.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/threading/RNFDispatcher.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/test/RNFTestHybridObject.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFEngineImpl.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFEngineImpl.Skybox.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFEngineWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFEngineConfigHelper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFSceneWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFCameraWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFViewWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFSwapChainWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFFilamentAssetWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFAnimatorWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFTransformManagerImpl.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFTransformManagerWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFAABBWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFBoxWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFMaterialInstanceWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFRenderableManagerImpl.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFRenderableManagerImpl.DebugHelpers.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFRenderableManagerWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFMaterialImpl.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFMaterialWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFFilamentInstanceWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFLightManagerWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/RNFRendererWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/utils/RNFEntityWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/utils/RNFManipulatorWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/core/math/RNFTMat44Wrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/bullet/RNFBulletWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/bullet/RNFDiscreteDynamicWorldWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/bullet/RNFRigidBodyWrapper.cpp.o CMakeFiles/react-native-filament.dir/Users/hannomargelo/Documents/Github/react-native-filament/package/cpp/bullet/RNFShapeWrapper.cpp.o CMakeFiles/react-native-filament.dir/src/main/cpp/RNFAndroidFilamentProxy.cpp.o CMakeFiles/react-native-filament.dir/src/main/cpp/RNFAndroidSurface.cpp.o CMakeFiles/react-native-filament.dir/src/main/cpp/RNFFilament.cpp.o CMakeFiles/react-native-filament.dir/src/main/cpp/RNFAndroidLogger.cpp.o CMakeFiles/react-native-filament.dir/src/main/cpp/RNFJNISharedPtr.cpp.o CMakeFiles/react-native-filament.dir/src/main/cpp/RNFFilamentInstaller.cpp.o CMakeFiles/react-native-filament.dir/src/main/cpp/java-bindings/RNFJFilamentProxy.cpp.o CMakeFiles/react-native-filament.dir/src/main/cpp/java-bindings/RNFJFilamentRecorder.cpp.o CMakeFiles/react-native-filament.dir/src/main/cpp/java-bindings/RNFJChoreographer.cpp.o CMakeFiles/react-native-filament.dir/src/main/cpp/java-bindings/RNFJFilamentView.cpp.o CMakeFiles/react-native-filament.dir/src/main/cpp/java-bindings/RNFJDispatcher.cpp.o CMakeFiles/react-native-filament.dir/src/main/cpp/java-bindings/RNFJSurfaceProvider.cpp.o /Users/hannomargelo/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/aarch64-linux-android/23/liblog.so -landroid /Users/hannomargelo/.gradle/caches/transforms-4/441abbc29e7844d504dda1a0ffede014/transformed/jetified-react-android-0.74.1-debug/prefab/modules/jsi/libs/android.arm64-v8a/libjsi.so /Users/hannomargelo/.gradle/caches/transforms-4/441abbc29e7844d504dda1a0ffede014/transformed/jetified-react-android-0.74.1-debug/prefab/modules/reactnativejni/libs/android.arm64-v8a/libreactnativejni.so /Users/hannomargelo/.gradle/caches/transforms-4/c7e26f7d3c2fc1a6636ff1467fc77795/transformed/jetified-fbjni-0.6.0/prefab/modules/fbjni/libs/android.arm64-v8a/libfbjni.so -lGLESv3 -lEGL /Users/hannomargelo/Documents/Github/react-native-filament/package/example/AppExamplePaper/node_modules/react-native-worklets-core/android/build/intermediates/cxx/Debug/54p5u1w1/obj/arm64-v8a/librnworklets.so ../../../../libs/filament/lib/arm64-v8a/libbackend.a ../../../../libs/filament/lib/arm64-v8a/libbasis_transcoder.a ../../../../libs/filament/lib/arm64-v8a/libbluevk.a ../../../../libs/filament/lib/arm64-v8a/libcamutils.a ../../../../libs/filament/lib/arm64-v8a/libcivetweb.a ../../../../libs/filament/lib/arm64-v8a/libdracodec.a ../../../../libs/filament/lib/arm64-v8a/libfilabridge.a ../../../../libs/filament/lib/arm64-v8a/libfilaflat.a ../../../../libs/filament/lib/arm64-v8a/libfilamat.a ../../../../libs/filament/lib/arm64-v8a/libfilament-iblprefilter.a ../../../../libs/filament/lib/arm64-v8a/libfilament.a ../../../../libs/filament/lib/arm64-v8a/libfilameshio.a ../../../../libs/filament/lib/arm64-v8a/libgeometry.a ../../../../libs/filament/lib/arm64-v8a/libgltfio_core.a ../../../../libs/filament/lib/arm64-v8a/libibl-lite.a ../../../../libs/filament/lib/arm64-v8a/libibl.a ../../../../libs/filament/lib/arm64-v8a/libimage.a ../../../../libs/filament/lib/arm64-v8a/libktxreader.a ../../../../libs/filament/lib/arm64-v8a/libmeshoptimizer.a ../../../../libs/filament/lib/arm64-v8a/libmikktspace.a ../../../../libs/filament/lib/arm64-v8a/libshaders.a ../../../../libs/filament/lib/arm64-v8a/libsmol-v.a ../../../../libs/filament/lib/arm64-v8a/libstb.a ../../../../libs/filament/lib/arm64-v8a/libuberarchive.a ../../../../libs/filament/lib/arm64-v8a/libuberzlib.a ../../../../libs/filament/lib/arm64-v8a/libutils.a ../../../../libs/filament/lib/arm64-v8a/libviewer.a ../../../../libs/filament/lib/arm64-v8a/libvkshaders.a ../../../../libs/filament/lib/arm64-v8a/libzstd.a ../../../../libs/bullet3/lib/arm64-v8a/libBullet.a -latomic -lm && :
ld: error: undefined symbol: std::__ndk1::__libcpp_verbose_abort(char const*, ...)
>>> referenced by BufferInterfaceBlock.cpp
>>> BufferInterfaceBlock.cpp.o:(std::__ndk1::__throw_length_error[abi:nn180000](char const*)) in archive ../../../../libs/filament/lib/arm64-v8a/libfilabridge.a
>>> referenced by BufferInterfaceBlock.cpp
>>> BufferInterfaceBlock.cpp.o:(std::__throw_bad_array_new_length[abi:nn180000]()) in archive ../../../../libs/filament/lib/arm64-v8a/libfilabridge.a
>>> referenced by VulkanPlatformSwapChainImpl.cpp
>>> VulkanPlatformSwapChainImpl.cpp.o:(std::__ndk1::__throw_out_of_range[abi:nn180000](char const*)) in archive ../../../../libs/filament/lib/arm64-v8a/libbackend.a
>>> referenced 2 more times
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

C++ build system [build] failed while executing:
/Users/hannomargelo/Library/Android/sdk/cmake/3.22.1/bin/ninja \
-C \
```

**Desktop (please complete the following information):**

n/a, android build process bug

**Smartphone (please complete the following information):**

n/a, android build process bug

**Additional context**
Due to other constraints we aren't able to upgrade to NDK 27 in our app, so thats not an option for us unfortunately.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.