Skip to content

Commit d4522b5

Browse files
authored
update linux arm instructions, closes tauri-apps#1539 (tauri-apps#1568)
* update linux arm instructions, closes tauri-apps#1539 * add instructions to fix/prevent issues with main packages
1 parent 69718c8 commit d4522b5

File tree

1 file changed

+105
-25
lines changed

1 file changed

+105
-25
lines changed

docs/guides/building/linux.md

Lines changed: 105 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ Manual compilation is suitable when you don't need to compile your application f
7575

7676
:::warning
7777

78-
Ubuntu 20.04 WSL has issues with webkit dependencies. It's recommended to use Debian instead.
79-
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:
78+
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:
8079

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

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

9392
1. Install Rust targets for your desired architecture:
93+
9494
- For ARMv7 (32-bit): `rustup target add armv7-unknown-linux-gnueabihf`
9595
- For ARMv8 (ARM64, 64-bit): `rustup target add aarch64-unknown-linux-gnu`
9696

9797
2. Install the corresponding linker for your chosen architecture:
98+
9899
- For ARMv7: `sudo apt install gcc-arm-linux-gnueabihf`
99100
- For ARMv8 (ARM64): `sudo apt install gcc-aarch64-linux-gnu`
100101

101102
3. Open or create the file `<project-root>/.cargo/config.toml` and add the following configurations accordingly:
103+
102104
```toml
103105
[target.armv7-unknown-linux-gnueabihf]
104106
linker = "arm-linux-gnueabihf-gcc"
105-
107+
106108
[target.aarch64-unknown-linux-gnu]
107109
linker = "aarch64-linux-gnu-gcc"
108110
```
109111

110-
4. Enable the respective architecture in the package manager (only for non-Debian distributions):
112+
4. Enable the respective architecture in the package manager:
113+
111114
- For ARMv7: `sudo dpkg --add-architecture armhf`
112115
- For ARMv8 (ARM64): `sudo dpkg --add-architecture arm64`
113116

114-
:::info Adjusting Package Sources
117+
5. Adjusting Package Sources
118+
119+
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):
115120

116-
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:
117121
```bash
118-
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy main restricted
119-
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted
120-
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy universe
121-
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-updates universe
122-
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy multiverse
123-
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-updates multiverse
124-
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiverse
125-
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted
126-
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-security universe
127-
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse
122+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricted
123+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted
124+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy universe
125+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates universe
126+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy multiverse
127+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates multiverse
128+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiverse
129+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted
130+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security universe
131+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse
128132
```
129-
After making changes, verify if the armhf architecture is still enabled in the package manager by re-running the command from Step 4.
130133

131-
:::
134+
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:
135+
136+
<details><summary>Click to see the full example file for Ubuntu 22.04</summary>
137+
138+
```bash
139+
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
140+
# newer versions of the distribution.
141+
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main restricted
142+
# deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted
143+
144+
## Major bug fix updates produced after the final release of the
145+
## distribution.
146+
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted
147+
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted
148+
149+
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
150+
## team. Also, please note that software in universe WILL NOT receive any
151+
## review or updates from the Ubuntu security team.
152+
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy universe
153+
# deb-src http://archive.ubuntu.com/ubuntu/ jammy universe
154+
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates universe
155+
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates universe
156+
157+
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
158+
## team, and may not be under a free licence. Please satisfy yourself as to
159+
## your rights to use the software. Also, please note that software in
160+
## multiverse WILL NOT receive any review or updates from the Ubuntu
161+
## security team.
162+
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy multiverse
163+
# deb-src http://archive.ubuntu.com/ubuntu/ jammy multiverse
164+
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse
165+
166+
## N.B. software from this repository may not have been tested as
167+
## extensively as that contained in the main release, although it includes
168+
## newer versions of some applications which may provide useful features.
169+
## Also, please note that software in backports WILL NOT receive any review
170+
## or updates from the Ubuntu security team.
171+
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
172+
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
173+
174+
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security main restricted
175+
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted
176+
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security universe
177+
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security universe
178+
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security multiverse
179+
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security multiverse
180+
181+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricted
182+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted
183+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy universe
184+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates universe
185+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy multiverse
186+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates multiverse
187+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiverse
188+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted
189+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security universe
190+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse
191+
```
192+
193+
</details>
132194

133-
5. Update the package information: `sudo apt-get update && sudo apt-get upgrade -y`.
195+
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.
196+
197+
6. Update the package information: `sudo apt-get update && sudo apt-get upgrade -y`.
198+
199+
7. Install the required webkitgtk library for your chosen architecture:
134200

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

139-
7. Set the `PKG_CONFIG_SYSROOT_DIR` to the appropriate directory based on your chosen architecture:
204+
8. Install OpenSSL or use a vendored version:
205+
206+
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`.
207+
208+
- Either install the development headers system-wide:
209+
- For ARMv7: `sudo apt install libssl-dev-dev:armhf`
210+
- For ARMv8 (ARM64): `sudo apt install libssl-dev-dev:arm64`
211+
- 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:
212+
213+
```toml
214+
openssl-sys = {version = "0.9", features = ["vendored"]}
215+
```
216+
217+
9. Set the `PKG_CONFIG_SYSROOT_DIR` to the appropriate directory based on your chosen architecture:
218+
140219
- For ARMv7: `export PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf/`
141220
- For ARMv8 (ARM64): `export PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu/`
142221

143-
8. Build the app for your desired ARM version:
144-
- For ARMv7: `cargo tauri build --target armv7-unknown-linux-gnueabihf`
145-
- For ARMv8 (ARM64): `cargo tauri build --target aarch64-unknown-linux-gnu`
222+
10. Build the app for your desired ARM version:
223+
224+
- For ARMv7: `cargo tauri build --target armv7-unknown-linux-gnueabihf`
225+
- For ARMv8 (ARM64): `cargo tauri build --target aarch64-unknown-linux-gnu`
146226

147227
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.
148228

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

155235
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:
236+
156237
```json
157238
"targets": ["deb", "nsis", "msi", "app", "dmg", "updater"],
158239
```
@@ -223,7 +304,6 @@ Adjust the `path` variable to match your application's version and name:
223304
[rust-lang/rust#57497]: https://github.com/rust-lang/rust/issues/57497
224305
[appimage guide]: https://docs.appimage.org/reference/best-practices.html#binaries-compiled-on-old-enough-base-system
225306
[fix-path-env-rs]: https://github.com/tauri-apps/fix-path-env-rs
226-
227307
[wsl setup guide]: https://www.linuxfordevices.com/tutorials/linux/install-debian-on-windows-wsl
228308
[system requirements]: https://tauri.app/v1/guides/getting-started/prerequisites#setting-up-linux
229309
[Tauri using Cargo]: https://tauri.app/v1/guides/getting-started/setup/next-js/#create-the-rust-project

0 commit comments

Comments
 (0)