Skip to content

Commit a4eb50a

Browse files
authored
docs: Port linux cross-arch compilation guide (#2981)
1 parent f1e5f9f commit a4eb50a

File tree

7 files changed

+354
-14
lines changed

7 files changed

+354
-14
lines changed

src/content/docs/distribute/appimage.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ i18nReady: true
99

1010
AppImages are convenient, simplifying the distribution process if you cannot make a package targeting the distribution's package manager. Still, you should carefully use it as the file size grows from the 2-6 MB range to 70+ MB.
1111

12+
:::note
13+
14+
GUI apps on macOS and Linux do not inherit the `$PATH` from your shell dotfiles (`.bashrc`, `.bash_profile`, `.zshrc`, etc). Check out Tauri's [fix-path-env-rs](https://github.com/tauri-apps/fix-path-env-rs) crate to fix this issue.
15+
16+
:::
17+
18+
## Limitations
19+
20+
Core libraries such as glibc frequently break compatibility with older systems. For this reason, you must build your Tauri application using the oldest base system you intend to support. A relatively old system such as Ubuntu 18.04 is more suited than Ubuntu 22.04, as the binary compiled on Ubuntu 22.04 will have a higher requirement of the glibc version, so when running on an older system, you will face a runtime error like `/usr/lib/libc.so.6: version 'GLIBC_2.33' not found`. We recommend using a Docker container or GitHub Actions to build your Tauri application for Linux.
21+
22+
See the issues [tauri-apps/tauri#1355](https://github.com/tauri-apps/tauri/issues/1355) and [rust-lang/rust#57497](https://github.com/rust-lang/rust/issues/57497), in addition to the [AppImage guide](https://docs.appimage.org/reference/best-practices.html#binaries-compiled-on-old-enough-base-system) for more information.
23+
1224
## Multimedia support via GStreamer
1325

1426
If your app plays audio/video you need to enable `tauri.conf.json > bundle > linux > appimage > bundleMediaFramework`. This will increase the size of the AppImage bundle to include additional gstreamer files needed for media playback. This flag is currently only fully supported on Ubuntu build systems. Make sure that your build system has all the plugins your app may need at runtime.

src/content/docs/distribute/debian.mdx

Lines changed: 160 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,24 @@ sidebar:
55
i18nReady: true
66
---
77

8-
{/* Is this about building .deb files, creating PPAs, or adding something to the debian/ubuntu repos? */}
9-
10-
## Debian
8+
import ShowSolution from '@components/ShowSolution.astro';
9+
import { Steps } from '@astrojs/starlight/components';
1110

1211
The stock Debian package generated by the Tauri bundler has everything you need to ship your application to Debian-based Linux distributions, defining your application's icons, generating a Desktop file, and specifying the dependencies `libwebkit2gtk-4.1-0` and `libgtk-3-0`, along with `libappindicator3-1` if your app uses the system tray.
1312

14-
### Custom Files
13+
:::note
14+
15+
GUI apps on macOS and Linux do not inherit the `$PATH` from your shell dotfiles (`.bashrc`, `.bash_profile`, `.zshrc`, etc). Check out Tauri's [fix-path-env-rs](https://github.com/tauri-apps/fix-path-env-rs) crate to fix this issue.
16+
17+
:::
18+
19+
## Limitations
20+
21+
Core libraries such as glibc frequently break compatibility with older systems. For this reason, you must build your Tauri application using the oldest base system you intend to support. A relatively old system such as Ubuntu 18.04 is more suited than Ubuntu 22.04, as the binary compiled on Ubuntu 22.04 will have a higher requirement of the glibc version, so when running on an older system, you will face a runtime error like `/usr/lib/libc.so.6: version 'GLIBC_2.33' not found`. We recommend using a Docker container or GitHub Actions to build your Tauri application for Linux.
22+
23+
See the issues [tauri-apps/tauri#1355](https://github.com/tauri-apps/tauri/issues/1355) and [rust-lang/rust#57497](https://github.com/rust-lang/rust/issues/57497), in addition to the [AppImage guide](https://docs.appimage.org/reference/best-practices.html#binaries-compiled-on-old-enough-base-system) for more information.
24+
25+
## Custom Files
1526

1627
Tauri exposes a few configurations for the Debian package in case you need more control.
1728

@@ -33,3 +44,148 @@ To include custom files in the Debian package, you can provide a list of files o
3344
}
3445
}
3546
```
47+
48+
## Cross-Compiling for ARM-based Devices
49+
50+
This guide covers manual compilation. Check out our [GitHub Action guide](/distribute/pipelines/github/#arm-runner-compilation) for an example workflow that leverages QEMU to build the app. This will be much slower but will also be able to build AppImages.
51+
52+
Manual compilation is suitable when you don't need to compile your application frequently and prefer a one-time setup. The following steps expect you to use a Linux distribution based on Debian/Ubuntu.
53+
54+
<Steps>
55+
56+
1. #### Install Rust targets for your desired architecture
57+
58+
- For ARMv7 (32-bit): `rustup target add armv7-unknown-linux-gnueabihf`
59+
- For ARMv8 (ARM64, 64-bit): `rustup target add aarch64-unknown-linux-gnu`
60+
61+
2. #### Install the corresponding linker for your chosen architecture
62+
63+
- For ARMv7: `sudo apt install gcc-arm-linux-gnueabihf`
64+
- For ARMv8 (ARM64): `sudo apt install gcc-aarch64-linux-gnu`
65+
66+
3. #### Open or create the file `<project-root>/.cargo/config.toml` and add the following configurations accordingly
67+
68+
```toml
69+
[target.armv7-unknown-linux-gnueabihf]
70+
linker = "arm-linux-gnueabihf-gcc"
71+
72+
[target.aarch64-unknown-linux-gnu]
73+
linker = "aarch64-linux-gnu-gcc"
74+
```
75+
76+
4. #### Enable the respective architecture in the package manager
77+
78+
- For ARMv7: `sudo dpkg --add-architecture armhf`
79+
- For ARMv8 (ARM64): `sudo dpkg --add-architecture arm64`
80+
81+
5. #### Adjusting Package Sources
82+
83+
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):
84+
85+
```
86+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricted
87+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted
88+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy universe
89+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates universe
90+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy multiverse
91+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates multiverse
92+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiverse
93+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted
94+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security universe
95+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse
96+
```
97+
98+
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:
99+
100+
<ShowSolution>
101+
102+
```
103+
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
104+
# newer versions of the distribution.
105+
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main restricted
106+
# deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted
107+
108+
## Major bug fix updates produced after the final release of the
109+
## distribution.
110+
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted
111+
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted
112+
113+
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
114+
## team. Also, please note that software in universe WILL NOT receive any
115+
## review or updates from the Ubuntu security team.
116+
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy universe
117+
# deb-src http://archive.ubuntu.com/ubuntu/ jammy universe
118+
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates universe
119+
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates universe
120+
121+
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
122+
## team, and may not be under a free licence. Please satisfy yourself as to
123+
## your rights to use the software. Also, please note that software in
124+
## multiverse WILL NOT receive any review or updates from the Ubuntu
125+
## security team.
126+
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy multiverse
127+
# deb-src http://archive.ubuntu.com/ubuntu/ jammy multiverse
128+
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse
129+
130+
## N.B. software from this repository may not have been tested as
131+
## extensively as that contained in the main release, although it includes
132+
## newer versions of some applications which may provide useful features.
133+
## Also, please note that software in backports WILL NOT receive any review
134+
## or updates from the Ubuntu security team.
135+
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
136+
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
137+
138+
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security main restricted
139+
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted
140+
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security universe
141+
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security universe
142+
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security multiverse
143+
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security multiverse
144+
145+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricted
146+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted
147+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy universe
148+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates universe
149+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy multiverse
150+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates multiverse
151+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiverse
152+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted
153+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security universe
154+
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse
155+
```
156+
157+
</ShowSolution>
158+
159+
6. #### Update the package information: `sudo apt-get update && sudo apt-get upgrade -y`
160+
161+
7. #### Install the required webkitgtk library for your chosen architecture
162+
163+
- For ARMv7: `sudo apt install libwebkit2gtk-4.1-dev:armhf`
164+
- For ARMv8 (ARM64): `sudo apt install libwebkit2gtk-4.1-dev:arm64`
165+
166+
8. #### Install OpenSSL or use a vendored version
167+
168+
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`.
169+
170+
- Either install the development headers system-wide:
171+
- For ARMv7: `sudo apt install libssl-dev:armhf`
172+
- For ARMv8 (ARM64): `sudo apt install libssl-dev:arm64`
173+
- 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:
174+
175+
```toml
176+
openssl-sys = {version = "0.9", features = ["vendored"]}
177+
```
178+
179+
9. #### Set the `PKG_CONFIG_SYSROOT_DIR` to the appropriate directory based on your chosen architecture
180+
181+
- For ARMv7: `export PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf/`
182+
- For ARMv8 (ARM64): `export PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu/`
183+
184+
10. #### Build the app for your desired ARM version
185+
186+
- For ARMv7: cargo tauri build --target armv7-unknown-linux-gnueabihf
187+
- For ARMv8 (ARM64): cargo tauri build --target aarch64-unknown-linux-gnu
188+
189+
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.
190+
191+
</Steps>

src/content/docs/distribute/dmg.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ To create an Apple Disk Image for your app you can use the Tauri CLI and run the
4141
alt="Standard DMG window"
4242
/>
4343

44+
:::note
45+
46+
GUI apps on macOS and Linux do not inherit the `$PATH` from your shell dotfiles (`.bashrc`, `.bash_profile`, `.zshrc`, etc). Check out Tauri's [fix-path-env-rs](https://github.com/tauri-apps/fix-path-env-rs) crate to fix this issue.
47+
48+
:::
49+
4450
## Window background
4551

4652
You can set a custom background image to the DMG installation window with the [`tauri.conf.json > bundle > macOS > dmg > background`] configuration option:

src/content/docs/distribute/macos-application-bundle.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ To package your app as a macOS application bundle you can use the Tauri CLI and
2121
cargo="cargo tauri build --bundles app"
2222
/>
2323

24+
:::note
25+
26+
GUI apps on macOS and Linux do not inherit the `$PATH` from your shell dotfiles (`.bashrc`, `.bash_profile`, `.zshrc`, etc). Check out Tauri's [fix-path-env-rs](https://github.com/tauri-apps/fix-path-env-rs) crate to fix this issue.
27+
28+
:::
29+
2430
## File structure
2531

2632
The macOS app bundle is a directory with the following structure:

0 commit comments

Comments
 (0)