跳转到主内容

构建步骤(Linux)

按照下面的指南在Linux下构建 Electron 本身,以此创建自定义 Electron 二进制文件。 For bundling and distributing your app code with the prebuilt Electron binaries, see the application distribution guide.

基本要求

Due to Electron's dependency on Chromium, prerequisites and dependencies for Electron change over time. Chromium's documentation on building on Linux has up to date information for building Chromium on Linux. This documentation can generally be followed for building Electron on Linux as well.

Additionally, Electron's Linux dependency installer can be referenced to get the current dependencies that Electron requires in addition to what Chromium installs via build/install-deps.sh.

交叉编译

If you want to build for an arm target, you can use Electron's Linux dependency installer to install the additional dependencies by passing the --arm argument:

$ sudo install-deps.sh --arm

And to cross-compile for arm or targets, you should pass the target_cpu parameter to gn gen:

$ gn gen out/Testing --args='import(...) target_cpu="arm"'

构建

See Build Instructions: GN

故障排查

加载共享库时出现错误: libtinfo.so.5

Prebuilt clang will try to link to libtinfo.so.5. Depending on the host architecture, symlink to appropriate libncurses:

$ sudo ln -s /usr/lib/libncurses.so.5 /usr/lib/libtinfo.so.5

高级提示

The default building configuration is targeted for major desktop Linux distributions. To build for a specific distribution or device, the following information may help you.

使用系统提供的 clang 替换下载的 clang 二进制文件

默认情况下, Electron 是由 Chromium 项目提供的预生成的 clang 二进制文件构建的。 如果出于某些原因你想用你系统已安装的 clang来构建,你可以在GN的参数中指定clang_base_path

例如如果你的 clang安装在 /usr/local/bin/clang下:

$ gn gen out/Testing --args='import("//electron/build/args/testing.gn") clang_base_path = "/usr/local/bin"'

使用 clang 之外的其它编译器

Electron 不支持除 clang之外的其他编译器构建