Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update linux arm instructions, closes #1539 #1568

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 105 additions & 25 deletions docs/guides/building/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ Manual compilation is suitable when you don't need to compile your application f

:::warning

Ubuntu 20.04 WSL has issues with webkit dependencies. It's recommended to use Debian instead.
Furthermore, AppImage is not supported on ARM devices. To avoid Tauri from building it, you need to customize tauri.conf.json in the src-tauri folder. Adjust the "targets" array to include only the desired platforms for your ARM-based device. For instance:
AppImage is not supported on ARM devices. To avoid Tauri from building it, you need to customize tauri.conf.json in the src-tauri folder. Adjust the "targets" array to include only the desired platforms for your ARM-based device. For instance:

"targets": ["deb", "nsis", "msi", "app", "dmg", "updater"],

Expand All @@ -91,58 +90,139 @@ Furthermore, AppImage is not supported on ARM devices. To avoid Tauri from build
Now, let's cross-compile the Tauri application for ARM:

1. Install Rust targets for your desired architecture:

- For ARMv7 (32-bit): `rustup target add armv7-unknown-linux-gnueabihf`
- For ARMv8 (ARM64, 64-bit): `rustup target add aarch64-unknown-linux-gnu`

2. Install the corresponding linker for your chosen architecture:

- For ARMv7: `sudo apt install gcc-arm-linux-gnueabihf`
- For ARMv8 (ARM64): `sudo apt install gcc-aarch64-linux-gnu`

3. Open or create the file `<project-root>/.cargo/config.toml` and add the following configurations accordingly:

```toml
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
```

4. Enable the respective architecture in the package manager (only for non-Debian distributions):
4. Enable the respective architecture in the package manager:

- For ARMv7: `sudo dpkg --add-architecture armhf`
- For ARMv8 (ARM64): `sudo dpkg --add-architecture arm64`

:::info Adjusting Package Sources
5. Adjusting Package Sources

On Debian, this step should not be necessary, but on other distributions, you might need to edit `/etc/apt/sources.list` to include the ARM architecture variant. For example on Ubuntu 22.04 add these lines to the bottom of the file (Remember to replace `jammy` with the codename of your Ubuntu version):

On Debian, this step isn't necessary, but on other distributions, you might need to edit `/etc/apt/sources.list` to include the ARM architecture variant. For example, add these lines:
```bash
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy main restricted
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy universe
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-updates universe
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy multiverse
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-updates multiverse
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-security universe
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricted
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy multiverse
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates multiverse
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiverse
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse
```
After making changes, verify if the armhf architecture is still enabled in the package manager by re-running the command from Step 4.

:::
Then, to prevent issues with the main packages, you have to add the correct main architecture to all other lines the file contained beforehand. For standard 64-bit systems you need to add `[arch=amd64]`, the full file on Ubuntu 22.04 then looks similar to this:

<details><summary>Click to see the full example file for Ubuntu 22.04</summary>

```bash
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main restricted
# deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy universe
# deb-src http://archive.ubuntu.com/ubuntu/ jammy universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates universe
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ jammy multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse

deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security main restricted
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security universe
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security universe
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security multiverse
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security multiverse

deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricted
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy multiverse
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates multiverse
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiverse
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse
```

</details>

5. Update the package information: `sudo apt-get update && sudo apt-get upgrade -y`.
After making these changes, verify that the armhf/arm64 architecture is still enabled in the package manager by re-running the command from Step 4.

6. Update the package information: `sudo apt-get update && sudo apt-get upgrade -y`.

7. Install the required webkitgtk library for your chosen architecture:

6. Install the required webkitgtk library for your chosen architecture:
- For ARMv7: `sudo apt install libwebkit2gtk-4.0-dev:armhf`
- For ARMv8 (ARM64): `sudo apt install libwebkit2gtk-4.0-dev:arm64`

7. Set the `PKG_CONFIG_SYSROOT_DIR` to the appropriate directory based on your chosen architecture:
8. Install OpenSSL or use a vendored version:

This is not always required so you may want to proceed first and check if you see errors like `Failed to find OpenSSL development headers`.

- Either install the development headers system-wide:
- For ARMv7: `sudo apt install libssl-dev-dev:armhf`
- For ARMv8 (ARM64): `sudo apt install libssl-dev-dev:arm64`
- Or enable the `vendor` feature for the OpenSSL Rust crate which will affect all other Rust dependencies using the same minor version. You can do so by adding this to the dependencies section in your `Cargo.toml` file:

```toml
openssl-sys = {version = "0.9", features = ["vendored"]}
```

9. Set the `PKG_CONFIG_SYSROOT_DIR` to the appropriate directory based on your chosen architecture:

- For ARMv7: `export PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf/`
- For ARMv8 (ARM64): `export PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu/`

8. Build the app for your desired ARM version:
- For ARMv7: `cargo tauri build --target armv7-unknown-linux-gnueabihf`
- For ARMv8 (ARM64): `cargo tauri build --target aarch64-unknown-linux-gnu`
10. Build the app for your desired ARM version:

- For ARMv7: `cargo tauri build --target armv7-unknown-linux-gnueabihf`
- For ARMv8 (ARM64): `cargo tauri build --target aarch64-unknown-linux-gnu`

Choose the appropriate set of instructions based on whether you want to cross-compile your Tauri application for ARMv7 or ARMv8 (ARM64). Please note that the specific steps may vary depending on your Linux distribution and setup.

Expand All @@ -153,6 +233,7 @@ For automated ARM executable builds on GitHub, we'll use the [arm-runner-action]
:::warning

AppImage is not supported on ARM devices. To avoid Tauri building it, you need to customize `tauri.conf.json` in the `src-tauri` folder. Adjust the `"targets"` array to include only the desired platforms for your ARM-based device. For instance:

```json
"targets": ["deb", "nsis", "msi", "app", "dmg", "updater"],
```
Expand Down Expand Up @@ -223,7 +304,6 @@ Adjust the `path` variable to match your application's version and name:
[rust-lang/rust#57497]: https://github.com/rust-lang/rust/issues/57497
[appimage guide]: https://docs.appimage.org/reference/best-practices.html#binaries-compiled-on-old-enough-base-system
[fix-path-env-rs]: https://github.com/tauri-apps/fix-path-env-rs

[wsl setup guide]: https://www.linuxfordevices.com/tutorials/linux/install-debian-on-windows-wsl
[system requirements]: https://tauri.app/v1/guides/getting-started/prerequisites#setting-up-linux
[Tauri using Cargo]: https://tauri.app/v1/guides/getting-started/setup/next-js/#create-the-rust-project
Expand Down