Debian
Tauri 打包器生成的标准 Debian 包包含您将应用程序发布到基于 Debian 的 Linux 发行版所需的一切,它定义了应用程序的图标,生成了桌面文件,并指定了依赖项 libwebkit2gtk-4.1-0
和 libgtk-3-0
,如果您的应用程序使用系统托盘,还会包含 libappindicator3-1
。
glibc 等核心库经常破坏与旧系统的兼容性。因此,您必须使用您打算支持的最旧的基础系统来构建您的 Tauri 应用程序。像 Ubuntu 18.04 这样相对较旧的系统比 Ubuntu 22.04 更适合,因为在 Ubuntu 22.04 上编译的二进制文件对 glibc 版本的要求更高,因此在旧系统上运行时,您将面临诸如 /usr/lib/libc.so.6: version 'GLIBC_2.33' not found
之类的运行时错误。我们建议使用 Docker 容器或 GitHub Actions 来构建您的 Linux 版 Tauri 应用程序。
有关更多信息,请参阅问题 tauri-apps/tauri#1355 和 rust-lang/rust#57497,以及 AppImage 指南。
Tauri 为 Debian 包提供了一些配置,以防您需要更多控制。
如果您的应用程序依赖于其他系统依赖项,您可以在 tauri.conf.json > bundle > linux > deb
中指定它们。
要在 Debian 包中包含自定义文件,您可以在 tauri.conf.json > bundle > linux > deb > files
中提供文件或文件夹列表。配置对象将 Debian 包中的路径映射到文件系统上的文件路径,该路径是相对于 tauri.conf.json
文件的。这是一个配置示例
{ "bundle": { "linux": { "deb": { "files": { "/usr/share/README.md": "../README.md", // copies the README.md file to /usr/share/README.md "/usr/share/assets": "../assets/" // copies the entire assets directory to /usr/share/assets } } } }}
本指南涵盖了手动编译。请查看我们的GitHub Action 指南,了解一个利用 QEMU 构建应用程序的示例工作流。这会慢得多,但也能构建 AppImages。
当您不需要频繁编译应用程序并更喜欢一次性设置时,手动编译是合适的。以下步骤假设您使用基于 Debian/Ubuntu 的 Linux 发行版。
-
- 对于 ARMv7 (32 位):
rustup target add armv7-unknown-linux-gnueabihf
- 对于 ARMv8 (ARM64, 64 位):
rustup target add aarch64-unknown-linux-gnu
- 对于 ARMv7 (32 位):
-
- 对于 ARMv7:
sudo apt install gcc-arm-linux-gnueabihf
- 对于 ARMv8 (ARM64):
sudo apt install gcc-aarch64-linux-gnu
- 对于 ARMv7:
-
[target.armv7-unknown-linux-gnueabihf]linker = "arm-linux-gnueabihf-gcc"[target.aarch64-unknown-linux-gnu]linker = "aarch64-linux-gnu-gcc"
-
- 对于 ARMv7:
sudo dpkg --add-architecture armhf
- 对于 ARMv8 (ARM64):
sudo dpkg --add-architecture arm64
- 对于 ARMv7:
-
在 Debian 上,此步骤应该不是必需的,但在其他发行版上,您可能需要编辑 /etc/apt/sources.list 以包含 ARM 架构变体。例如,在 Ubuntu 22.04 上,将这些行添加到文件底部(请记住将 jammy 替换为您的 Ubuntu 版本代号)
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricteddeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricteddeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy universedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates universedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy multiversedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates multiversedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiversedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricteddeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security universedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse然后,为了防止主软件包出现问题,您必须将正确的主架构添加到文件之前包含的所有其他行中。对于标准 64 位系统,您需要添加 [arch=amd64],Ubuntu 22.04 上的完整文件如下所示
# 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 universedeb [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 multiversedeb [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 multiversedeb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security main restricted# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricteddeb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security universe# deb-src http://security.ubuntu.com/ubuntu/ jammy-security universedeb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security multiverse# deb-src http://security.ubuntu.com/ubuntu/ jammy-security multiversedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricteddeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricteddeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy universedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates universedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy multiversedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates multiversedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main restricted universe multiversedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricteddeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security universedeb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse -
- 对于 ARMv7:
sudo apt install libwebkit2gtk-4.1-dev:armhf
- 对于 ARMv8 (ARM64):
sudo apt install libwebkit2gtk-4.1-dev:arm64
- 对于 ARMv7:
-
这并非总是必需,因此您可以先尝试,并检查是否出现类似
Failed to find OpenSSL development headers
的错误。- 要么在系统范围内安装开发头文件
- 对于 ARMv7:
sudo apt install libssl-dev:armhf
- 对于 ARMv8 (ARM64):
sudo apt install libssl-dev:arm64
- 对于 ARMv7:
- 或者为 OpenSSL Rust crate 启用 vendored 功能,这将影响所有使用相同次要版本的其他 Rust 依赖项。您可以通过将此添加到
Cargo.toml
文件中的依赖项部分来做到这一点
openssl-sys = {version = "0.9", features = ["vendored"]} - 要么在系统范围内安装开发头文件
-
- 对于 ARMv7:
export PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf/
- 对于 ARMv8 (ARM64):
export PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu/
- 对于 ARMv7:
-
- 对于 ARMv7:cargo tauri build —target armv7-unknown-linux-gnueabihf
- 对于 ARMv8 (ARM64):cargo tauri build —target aarch64-unknown-linux-gnu
根据您是要为 ARMv7 还是 ARMv8 (ARM64) 交叉编译 Tauri 应用程序,选择适当的说明集。请注意,具体步骤可能因您的 Linux 发行版和设置而异。
© 2025 Tauri 贡献者。CC-BY / MIT