从源码编译 ArtCraft 系列:以 PhotoCraft 为例
环境准备、克隆、编译、排错一条龙:在任何系统上把 ArtCraft 最新源码编译成本地可执行程序。
LightCraft、PrintCraft、DesignCraft 还没发布安装包,想第一时间体验最新功能、或者想给官方修 Bug,从源码编译是唯一的路。ArtCraft 全系软件是 Rust 项目,编译流程高度一致,本教程以 PhotoCraft 为例,其他产品只换仓库名。
各软件的编译要求速查
| 软件 | 仓库 | Rust 版本 | 平台 |
|---|---|---|---|
| PhotoCraft | storytold/photocraft | 1.90+ | macOS / Windows / Linux / Web |
| VectorCraft | storytold/vectorcraft | 1.90+ | macOS / Windows / Linux / Web |
| FilmCraft | storytold/filmcraft | 1.95+ | macOS / Windows / Linux |
| LightCraft | storytold/lightcraft | 1.90+ | macOS / Windows / Linux / Web |
| PrintCraft | storytold/pdfcraft(注意仓库名) | 1.90+ | macOS / Windows / Linux / Web |
| EffectCraft | storytold/effectcraft | 1.95+ | macOS / Windows / Linux / Web |
| DesignCraft | storytold/designcraft | 1.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/Debian | build-essential pkg-config libssl-dev,以及图形相关 libx11-dev 等 |
| Fedora | gcc openssl-devel 与 X11/Wayland 开发包 |
| macOS | Xcode Command Line Tools(xcode-select --install) |
| Windows | Visual 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)略有差异,以仓库文档为准。
给官方贡献代码
- 在 GitHub Fork 仓库,克隆你的 fork
- 新建分支:
git checkout -b fix/my-fix - 修改 + 本地验证(
cargo build/cargo test) - 提交并发起 Pull Request,描述清楚改动动机与验证方式
- 重大改动建议先开 Issue 或到 Discord 讨论
小结
- 万变不离其宗:rustup → 系统依赖 →
cargo build --release - PrintCraft 仓库名是 pdfcraft,FilmCraft/EffectCraft 要求 Rust 1.95+
- Linux 图形库缺失是第一大坑,看报错第一行装
-dev包 - 编译通过之后,你就具备了给开源项目提 PR 的全部前置技能
相关教程
本教程由社区贡献,内容基于 ArtCraft 软件早期版本,功能与界面可能随版本更新变化。ArtCraft 系列软件当前处于早期开发阶段,请在重要项目前自行备份文件。本站为非官方社区站点,与 storytold 团队没有隶属关系。