# Tried to build Anki for Termux on android using recently added packages pyqt5 and pyqtwebwngine

**URL:** <https://forums.ankiweb.net/t/tried-to-build-anki-for-termux-on-android-using-recently-added-packages-pyqt5-and-pyqtwebwngine/26583>\
**Category:** Development\
**Created:** [January 20, 2023, 3:55pm UTC](https://forums.ankiweb.net/t/tried-to-build-anki-for-termux-on-android-using-recently-added-packages-pyqt5-and-pyqtwebwngine/26583 "2023-01-20T15:55:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![krmanik](https://avatars.discourse-cdn.com/v4/letter/k/d6d6ee/32.png) [@krmanik](https://forums.ankiweb.net/u/krmanik)\
**Post date:** [January 20, 2023, 3:55pm UTC](https://forums.ankiweb.net/t/tried-to-build-anki-for-termux-on-android-using-recently-added-packages-pyqt5-and-pyqtwebwngine/26583/1 "2023-01-20T15:55:00Z")

</div>

I have tried to build anki in termux, the wheels successfully built but anki is not running giving following errors.

```auto
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` and `tur-repo`

```auto
pkg install x11-repo
pkg install tur-repo

```

## 1. Install required packages

1. Install `PyQt5` and `PyQtWebEngine`

2. Install required packages

3. Install `pip-tools` for `pip-sync`

4. Build and install `maturin` and `orjson`, it will takes time to build

## 2. Build Anki

1. Export variables for `Python` binary and path

2. Clone anki source

3. Download [android.patch](https://gist.github.com/krmanik/1230b138ce4308e93c512265006b6a8a)

4. Apply patch to anki for using `android.patch`.  
The patch changes `PyQt5`, `PyQtWebEngine` and `orjson` version and copy `nodejs` and `protoc` from `/usr/bin/` dir to `out/extracted/` dir.

5. It needs to do change in `anki/out/pyenv/pyvenv.cfg` to use `system-site-packages` after creation of pyenv in `anki/out/pyenv` or when errors occur.

6. It needs to manually copy this file, the patch is not updating it.

## 3. Result

1. Result for building wheels, `./tools/build`

```auto
~/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

```

1. Result for `./run`

```auto
~/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"...

```

## Download built wheel and related packages

- [anki-2.1.57.zip](https://github.com/krmanik/anki-arm64/files/10467839/anki-2.1.57.zip)
- [orjson - maturin.zip](https://github.com/krmanik/anki-arm64/files/10467844/orjson.-.maturin.zip)

---

<div class="post-metadata">

**Author:** ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)\
**Post date:** [January 20, 2023, 11:27pm UTC](https://forums.ankiweb.net/t/tried-to-build-anki-for-termux-on-android-using-recently-added-packages-pyqt5-and-pyqtwebwngine/26583/2 "2023-01-20T23:27:22Z")

</div>

> [@krmanik](#):
>
> `__extenddftf2`

Maybe downgrading Rust to 1.64 will help. [[Bug]: Rust compiling rusqlite fails in rust 1.66.1: error: undefined symbol: `__extenddftf2` · Issue #14576 · termux/termux-packages · GitHub](https://github.com/termux/termux-packages/issues/14576)

---

<div class="post-metadata">

**Author:** ![krmanik](https://avatars.discourse-cdn.com/v4/letter/k/d6d6ee/32.png) [@krmanik](https://forums.ankiweb.net/u/krmanik)\
**Post date:** [January 23, 2023, 3:57am UTC](https://forums.ankiweb.net/t/tried-to-build-anki-for-termux-on-android-using-recently-added-packages-pyqt5-and-pyqtwebwngine/26583/3 "2023-01-23T03:57:38Z")

</div>

I have tried rust 1.64.0 but getting `segmentation fault`. I will test 1.65.0 later.  
[used rust 1.64.0 to build · GitHub](https://gist.github.com/krmanik/1e1eef5e1fb8176dcd643433ea26e07e)

Three changes needs to be done in anki source.

1. Python pyenv creation with `--system-site-packages`. I have done using following.

2. Protoc binary used from installed directory instead of downloaded version. I have completed it in this commit and will create PR for this.  
[Comparing ankitects:main...krmanik:protoc-binary-path · ankitects/anki · GitHub](https://github.com/ankitects/anki/compare/main...krmanik:anki:protoc-binary-path)

3. Also node js binary and its folder from path, I have tried but need help here.  
[Comparing ankitects:main...krmanik:node-binary-path · ankitects/anki · GitHub](https://github.com/ankitects/anki/compare/main...krmanik:anki:node-binary-path)

---

<div class="post-metadata">

**Author:** ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)\
**Post date:** [January 23, 2023, 7:29am UTC](https://forums.ankiweb.net/t/tried-to-build-anki-for-termux-on-android-using-recently-added-packages-pyqt5-and-pyqtwebwngine/26583/4 "2023-01-23T07:29:45Z")

</div>

I don’t mind accepting changes to the build scripts to optionally swap out dependencies with local binaries, but the current approach is a bit messy. Please see the commit I just pushed to the main branch, which should require fewer changes when switching out things.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)\
**Post date:** [February 22, 2023, 7:30am UTC](https://forums.ankiweb.net/t/tried-to-build-anki-for-termux-on-android-using-recently-added-packages-pyqt5-and-pyqtwebwngine/26583/5 "2023-02-22T07:30:18Z")

</div>

Closed on February 22, 2023, 7:30am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
