通用教程源码编译

从源码编译 ArtCraft 系列:以 PhotoCraft 为例

环境准备、克隆、编译、排错一条龙:在任何系统上把 ArtCraft 最新源码编译成本地可执行程序。

老尘2026-10-01约 7 分钟

LightCraft、PrintCraft、DesignCraft 还没发布安装包,想第一时间体验最新功能、或者想给官方修 Bug,从源码编译是唯一的路。ArtCraft 全系软件是 Rust 项目,编译流程高度一致,本教程以 PhotoCraft 为例,其他产品只换仓库名。

各软件的编译要求速查

软件仓库Rust 版本平台
PhotoCraftstorytold/photocraft1.90+macOS / Windows / Linux / Web
VectorCraftstorytold/vectorcraft1.90+macOS / Windows / Linux / Web
FilmCraftstorytold/filmcraft1.95+macOS / Windows / Linux
LightCraftstorytold/lightcraft1.90+macOS / Windows / Linux / Web
PrintCraftstorytold/pdfcraft(注意仓库名)1.90+macOS / Windows / Linux / Web
EffectCraftstorytold/effectcraft1.95+macOS / Windows / Linux / Web
DesignCraftstorytold/designcraft1.90+macOS / Windows / Linux / Web

PrintCraft 的 GitHub 仓库名是 pdfcraft,输入 printcraft 会被重定向,克隆时直接用正确名字。

准备 Rust 环境

安装 rustup(推荐)

# macOS / Linux
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Windows
# 到 https://rustup.rs 下载 rustup-init.exe 运行

装完后确认版本,ArtCraft 对 Rust 版本要求较新(1.90/1.95+),低了会编译失败:

rustc --version

版本太旧就升级:

rustup update stable

各平台额外依赖

平台依赖
Ubuntu/Debianbuild-essential pkg-config libssl-dev,以及图形相关 libx11-dev 等
Fedoragcc openssl-devel 与 X11/Wayland 开发包
macOSXcode Command Line Tools(xcode-select --install)
WindowsVisual Studio 2022 的「使用 C++ 的桌面开发」工作负载

Linux 上缺图形库是新手第一大坑:报错信息里出现 X11、wayland、vulkan 字样,多半是缺系统开发包。把报错第一行拿去搜索,装上对应 -dev 包即可。

克隆与编译

git clone https://github.com/storytold/photocraft.git
cd photocraft

# Debug 版:编译快,用于运行和调试(二进制大、运行慢)
cargo run

# Release 版:优化后的正式构建(编译久,运行快)
cargo build --release

编译产物位置:

  • Debug:target/debug/photocraft
  • Release:target/release/photocraft

首次编译要拉取并构建全部依赖,耐心等下载与编译日志滚动;第二次起有缓存,速度飞快。

修改一行代码试试

验证开发环境可用最直接的方式是动一刀。找一处 UI 文案(用编辑器全局搜索一个菜单字符串),改成你想要的文字,然后 cargo run 看变化。能编译能运行,说明你可以开始给官方提 PR 了。

常见编译错误排查

error: failed to run custom build command for openssl

缺 OpenSSL 开发包。Linux 装系统包;macOS 用 Homebrew 装 openssl@3;Windows 一般不涉及(Rust 用 vendored 特性)。

linker cc not found

没装 C/C++ 工具链。Linux 装 build-essential/gcc,Windows 装好 Visual Studio C++ 工作负载,macOS 装 Xcode CLT。

rustc ... is not supported by the following packages

Rust 版本低于软件要求。rustup update stable 升级即可(再不行就 rustup install beta 试试)。

编译中途卡在 vulkan / wgpu 相关报错

图形后端开发头文件缺失,Linux 装 libvulkan-dev、vulkan-tools 等。wgpu 的构建脚本对驱动头文件有要求,报错信息会指明缺什么。

构建 Web 版(WASM)

PhotoCraft/VectorCraft 等带 Web 版的软件可以编译到浏览器:

rustup target add wasm32-unknown-unknown
cargo install trunk   # Web 应用打包工具(若仓库使用 trunk)
# 具体以各仓库 README 的 Web 章节为准

各仓库的 Web 构建细节(trunk / wasm-pack)略有差异,以仓库文档为准。

给官方贡献代码

  1. 在 GitHub Fork 仓库,克隆你的 fork
  2. 新建分支:git checkout -b fix/my-fix
  3. 修改 + 本地验证(cargo build / cargo test)
  4. 提交并发起 Pull Request,描述清楚改动动机与验证方式
  5. 重大改动建议先开 Issue 或到 Discord 讨论

小结

  • 万变不离其宗:rustup → 系统依赖 → cargo build --release
  • PrintCraft 仓库名是 pdfcraft,FilmCraft/EffectCraft 要求 Rust 1.95+
  • Linux 图形库缺失是第一大坑,看报错第一行装 -dev 包
  • 编译通过之后,你就具备了给开源项目提 PR 的全部前置技能

相关教程

本教程由社区贡献,内容基于 ArtCraft 软件早期版本,功能与界面可能随版本更新变化。ArtCraft 系列软件当前处于早期开发阶段,请在重要项目前自行备份文件。本站为非官方社区站点,与 storytold 团队没有隶属关系。