Building filament 1.67 for Android on mac - AI powered #9432
pannonianknight
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
recently i had started to thinker and experiment with filament. Need a lightweight multiplatform render engine.
Im more a designer then developer, heck, honestly, im not even a D in that word developer. But i found some courage in Cursor and other llms.
I managed to get filament working on iOS, was a fight but it works.
Then came andorid, boy was it hair pulling.
But i managed. Tought i share my findings with the world. Maybe could save some one some hair.
Filament Build Instructions for Android
Documentation for building Filament rendering engine for Android with
c++_sharedstandard library and C++17 standard.📋 Prerequisites
Android SDK & NDK
25.1.8937393/Users/marko/Library/Android/sdk/ndk/25.1.89373933.22.1(comes with Android SDK)Java
Build Tools
🔧 Filament Build Configuration
1. C++ Standard Library:
c++_sharedProblem:
gltfio::ResourceLoaderusesstd::stringstreamwhich has known linking issues withc++_staticon Android NDK.Solution: Build Filament with
c++_sharedinstead ofc++_static.2. C++ Standard: C++17 with C++20 Extensions
Problem: Filament source uses some C++20 features (e.g.,
explicit capture of 'this' with a capture default of '=').Solution: Build with C++17 standard but allow C++20 extensions.
📝 Build Steps
Step 1: Create
filament-cpp17.cmakeCreate the file in Filament root directory:
Location:
/Users/marko/Desktop/OpenSource/filament/filament-cpp17.cmakeStep 2: Include
filament-cpp17.cmakein Filament CMakeLists.txtAdd at the beginning of the main
CMakeLists.txt:Location:
/Users/marko/Desktop/OpenSource/filament/CMakeLists.txtStep 3: Update Android build.gradle
Change
-DANDROID_STL=c++_staticto-DANDROID_STL=c++_shared:Location:
/Users/marko/Desktop/OpenSource/filament/android/build.gradleStep 4: Build Filament
Build Output:
/Users/marko/Desktop/OpenSource/filament/out/android-release/filamentlib/${ANDROID_ABI}/lib*.ainclude/Step 5: Verify Build Output
You should see:
libfilament.alibgltfio_core.alibktxreader.alibbasis_transcoder.a🔗 Android App Integration
1. CMakeLists.txt Configuration
2. Gradle Configuration
3. Include
libc++_shared.soin APKOption A: Manual Copy (Recommended)
mkdir -p app/src/main/jniLibs/arm64-v8a cp ${ANDROID_NDK}/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so \ app/src/main/jniLibs/arm64-v8a/Option B: Gradle sourceSets (Alternative)
sourceSets { getByName("main") { jniLibs.srcDirs( "src/main/jniLibs", "${android.ndkDirectory}/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/aarch64-linux-android" ) } }✅ Build Verification
1. Verify if the app builds
cd /Users/marko/Desktop/GIT/3d-companion-app-filament-Android ./gradlew :app:assembleDebug2. Verify that
libc++_shared.soexists in APKunzip -l app/build/outputs/apk/debug/app-debug.apk | grep libc++_shared.so3. Runtime Verification
In logcat you should see:
🐛 Resolved Issues
Issue 1:
stringstreamLinker ErrorError:
ld: error: undefined symbol: vtable for std::__ndk1::basic_stringstreamSolution: Switch from
c++_statictoc++_sharedin Filament build and app configuration.Issue 2: C++20 Extensions Error
Error:
explicit capture of 'this' with a capture default of '=' is a C++20 extensionSolution: Add
-Wno-c++20-extensionsflag to compiler options.Issue 3:
libc++_shared.soNot FoundError:
java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not foundSolution: Copy
libc++_shared.sofrom NDK toapp/src/main/jniLibs/arm64-v8a/.📦 Build Artifacts
Filament Libraries (arm64-v8a)
Filament Headers
🔄 Rebuild Filament
If you need to rebuild Filament after changes:
📚 Reference
✨ Final Notes
c++_shared(required for ResourceLoader)Date: 2025-11-12
Filament Version: Latest (from OpenSource/filament)
Android NDK: 25.1.8937393
CMake: 3.22.1
Beta Was this translation helpful? Give feedback.
All reactions