I have tried to build anki in termux, the wheels successfully built but anki is not running giving following errors.
ImportError: dlopen failed: cannot locate symbol "__extenddftf2" referenced by "/data/data/com.termux/files/home/anki/out/rust/debug/librsbridge.so"...
0. Requirements for building
- aarch64
- 10 GB space on device
- install
x11-repo
andtur-repo
pkg install x11-repo pkg install tur-repo
1. Install required packages
-
Install
PyQt5
andPyQtWebEngine
pkg install pyqt5 python-pyqtwebengine
-
Install required packages
pkg install wget grep findutils curl git rsync ninja binutils rust protobuf nodejs-lts python3.9
-
Install
pip-tools
forpip-sync
pip install pip-tools
-
Build and install
maturin
andorjson
, it will takes time to buildexport RUSTFLAGS+=" -C lto=no" CARGO_BUILD_TARGET=aarch64-linux-android pip install maturin==0.14.10 CARGO_BUILD_TARGET=aarch64-linux-android pip install orjson==3.8.5
2. Build Anki
-
Export variables for
Python
binary and pathexport PYTHON_BINARY=/data/data/com.termux/files/usr/bin/python export PYTHONPATH=/data/data/com.termux/files/usr/lib/python3.11/site-packages
-
Clone anki source
git clone --recurse-submodules https://github.com/ankitects/anki.git
It may needs to checkout to this commit hash
c8275257ce4f507cf3292d6d4d7185d05088e310
before applying patch.git checkout c8275257ce4f507cf3292d6d4d7185d05088e310 -b termux-android
-
Download android.patch
wget https://gist.githubusercontent.com/krmanik/1230b138ce4308e93c512265006b6a8a/raw/8a7027dace3b5e2f72da0bc60350f07728abbf26/android.patch
-
Apply patch to anki for using
android.patch
.
The patch changesPyQt5
,PyQtWebEngine
andorjson
version and copynodejs
andprotoc
from/usr/bin/
dir toout/extracted/
dir.cd anki git apply ../android.patch ./run
-
It needs to do change in
anki/out/pyenv/pyvenv.cfg
to usesystem-site-packages
after creation of pyenv inanki/out/pyenv
or when errors occur.include-system-site-packages = true
Tried to add
--system-site-package
toanki/build/ninja_gen/src/python.rs
but didn’t work. -
It needs to manually copy this file, the patch is not updating it.
cd anki # remove rm out/extracted/protoc/bin/protoc rm out/extracted/node/bin/node # copy cp /data/data/com.termux/files/usr/bin/protoc out/extracted/protoc/bin/protoc cp /data/data/com.termux/files/usr/bin/node out/extracted/node/bin/node
3. Result
- Result for building wheels,
./tools/build
~/anki $ ./tools/build
Finished dev [unoptimized + debuginfo] target(s) in 2.32s
[29/29; 1 active; 1087.665s] wheels:anki
Build succeeded.
wheels are in out/wheels
- Result for
./run
~/anki $ ./run
Finished dev [unoptimized + debuginfo] target(s) in 2.36s
[26/26; 1 active; 115.654s] qt/aqt:data/web/js
Build succeeded.
Traceback (most recent call last):
File "/data/data/com.termux/files/home/anki/tools/run.py", line 9, in <module>
import aqt
File "/data/data/com.termux/files/home/anki/qt/aqt/__init__.py", line 40, in <module>
import anki.lang
File "/data/data/com.termux/files/home/anki/pylib/anki/lang.py", line 12, in <module>
import anki._backend
File "/data/data/com.termux/files/home/anki/pylib/anki/_backend.py", line 14, in <module>
from anki import _rsbridge, backend_pb2, i18n_pb2
ImportError: dlopen failed: cannot locate symbol "__extenddftf2" referenced by "/data/data/com.termux/files/home/anki/out/rust/debug/librsbridge.so"...