一、Filament 源代码下载
github下载地址:https://github.com/google/filament
|
如我本地:
|
二、Filament for Android 编译
参考官方资料:https://github.com/google/filament/blob/main/BUILDING.md
需要的工具:
Prerequisites
To build Filament, you must first install the following tools:
- CMake 3.19 (or more recent)
- clang 7.0 (or more recent)
- ninja 1.10 (or more recent)
Additional dependencies may be required for your operating system. Please refer to the appropriate section below.
To build Filament for Android you must also install the following:
- Android Studio Arctic Fox or more recent
- Android SDK
- Android NDK 25.1 or higher
1、 安装cmake
|
如果本地没有安装过cmake,输入cmake命令提示:
|
|
如果是3.19以下版本,使用下面方法更新到最新版本
打开cmake下载的官网:https://cmake.org/files/
下载最新版本
sudo bash cmake-3.25.1-linux-x86_64.sh --skip-licence --prefix=/usr
在弹出来的提示中,输入y/n
|
这时会自动安装了
2、安装clang
我是直接安装clang-10
Ubuntu 20.04 ,sudo apt install clang 命令默认就是clang-10
|
3、安装ninja
|
4、安装Android Studio
google android developers官网下载最新的:https://developer.android.com/studio,
下载最新Android Studio的后(当前最新版本为:android-studio-2021.3.1.17-linux.tar.gz)
直接解压即可
我本地是:
|
运行直接到android-studio/bin目录,执行./studio.sh
注意:如果之前有安装过老的版本Android Studio,在导入filament/android时可能会提示版本或插件不兼容问题
我本地就遇到了这个问题
|
解决方案就是更新Android Studio版本和插件
5、Android Studio安装cmake和NDK
打开Android studio -> Tools -> SDK Manager
首先建议安装最新的SDK ,注意选择自己的安装路径,记录号安装路径,后面配置环境变量需要用到
到SDK目录看一下安装的版本:如我本地安装目录是/home/liuzhengliang/Android/Sdk/
6、配置环境变量
vim ~/.bashrc
添加, 路径换成自己的sdk目录
|
重启机器,或者在编译filament的终端执行source ~/.bashrc
三、Filament 在Ubuntu系统上编译
|
编译成功后会在out生成如下所示目录
进入到 out/cmake-release 目录下:
|
四、Android studio运行 filament samples
Android studio 直接open filament下的android目录
方法:打开Android studio -> File -> Open
需要debug的手机链接到PC电脑(记得开启adb debug)
- 选择需要运行的samples
- 链接到手机adb
- 点击Run编译并运行
如samples:sample-gltf-viewer的效果:
五、其他问题记录
1. 我本地编译报遇到过:'X11/extensions/xf86vmode.h' file not found
/home/liuzhengliang/22-code/filament/filament/third_party/libsdl2/src/video/x11/SDL_x11video.h:56:10: fatal error: 'X11/extensions/xf86vmode.h' file not found
#include <X11/extensions/xf86vmode.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
解决方法:
sudo apt-get install libxxf86vm-dev |
2. ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
解决方法:
安装openjdk sudo apt-get install openjdk-11-jdk |
3. ccache: error: SLOPPINESS: unknown sloppiness: "locale"
ccache: error: SLOPPINESS: unknown sloppiness: "locale"
解决方法:
编译时遇到ccache报错: 解决方案:卸载本地的ccache 或者更新到最新ccache版本 |
4. fatal error: 'type_traits' file not found #include <type_traits>
报错:/home/liqinyan/data/source_code/3d_filament_code/google-filament/filament/libs/math/include/math/compiler.h:20:10: fatal error: 'type_traits' file not found #include <type_traits> ^~~~~~~~~~~~~ 1 error generated. ninja: build stopped: subcommand failed.
解决方法:
缺少c++相关库,重新执行下面的命令 |