-
Notifications
You must be signed in to change notification settings - Fork 55
Building flutter apps
Use --target-backend-type
option to select display backends. Default is Wayland.
Build mode | Target backend | Command |
---|---|---|
release | wayland | flutter-elinux build elinux |
x11 | flutter-elinux build elinux --target-backend-type=x11 |
|
gbm | flutter-elinux build elinux --target-backend-type=gbm |
|
eglstream | flutter-elinux build elinux --target-backend-type=eglstream |
|
debug | wayland | flutter-elinux build elinux --debug |
x11 | flutter-elinux build elinux --debug --target-backend-type=x11 |
|
gbm | flutter-elinux build elinux --debug --target-backend-type=gbm |
|
eglstream | flutter-elinux build elinux --debug --target-backend-type=eglstream |
|
profile | wayland | flutter-elinux build elinux --profile |
x11 | flutter-elinux build elinux --profile --target-backend-type=x11 |
|
gbm | flutter-elinux build elinux --profile --target-backend-type=gbm |
|
eglstream | flutter-elinux build elinux --profile --target-backend-type=eglstream |
Cross-building requires knowledge (Not easy, you might get build errors). You need to prepare your sysroot which is for cross-building for your target device by using --target-sysroot
. Also, Use --target-arch
option to specify arm64 targets. Default is current host CPU architecture.
$ flutter-elinux build elinux --target-arch=arm64 --target-sysroot=<path_to_target's_sysroot>
There are some ways to create a sysroot like Yocto, buildroot, and so on. Here, we show an example using a sysroot for arm64v8/ubuntu:18.04 docker image, but using sysroot and toolchain for your target device is better.
$ sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
$ sudo apt install libstdc++-8-dev-arm64-cross
First, install Docker by following Install Docker Engine on Ubuntu.
S sudo apt install qemu-user-static
$ sudo docker run -it arm64v8/ubuntu:18:04
In docker:
apt install clang cmake build-essential \
pkg-config libegl1-mesa-dev \
libxkbcommon-dev libgles2-mesa-dev
apt install libwayland-dev wayland-protocols
exit
Copy sysroot from the container to host:
$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f367a6b0316f arm64v8/ubuntu:18.04 "bash" 4 hours ago Exited (0) 4 hours ago interesting_knuth
$ mkdir ubuntu18-arm64-sysroot
$ sudo docker cp f367a6b0316f:/ ubuntu18-arm64-sysroot
$ flutter-elinux build elinux --target-arch=arm64 \
--target-sysroot=<Absolute_path_to>/ubuntu18-arm64-sysroot
If you get the following error, use --system-include-directories
option.
/usr/bin/../lib/gcc-cross/aarch64-linux-gnu/9/../../../../include/c++/9/casse
rt:43:10: fatal error: 'bits/c++config.h' file not found
#include <bits/c++config.h>
^~~~~~~~~~~~~~~~~~
$ flutter-elinux build elinux --target-arch=arm64 \
--target-sysroot=<Absolute_path_to>/ubuntu18-arm64-sysroot \
--system-include-directories=/usr/aarch64-linux-gnu/include/c++/${version}/aarch64-linux-gnu
The artifacts will be put in build/${target-arch}/${build-mode}/bundle
.