You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu下Rust链接静态库遇阻:缺失SDL2相关依赖求助

解决SDL2_mixer/SDL2_image链接错误的方案

1. 安装缺失的系统依赖库

你只安装了libsdl2-dev,但错误提示找不到的是SDL2_mixer和SDL2_image的开发库,执行以下命令补装:

sudo apt-get install libsdl2-mixer-dev libsdl2-image-dev

安装完成后重新运行cargo run --release,问题大概率会解决。

2. 使用bundled特性静态编译(不依赖系统库)

如果不想依赖系统上的SDL库,可以启用gate的bundled特性,让项目从源码编译并静态链接SDL2_mixer和SDL2_image。修改你的Cargo.toml中gate的依赖配置:

# 若使用crates.io版本
gate = { version = "0.10.0", features = ["bundled"] }

# 若使用git仓库版本
gate = { git = "https://github.com/SergiusIW/gate", features = ["bundled"] }

配置完成后执行cargo run --release即可完成静态编译。

3. 使用use-pkgconfig特性(强制通过pkgconfig检测系统库)

如果希望继续使用系统库,但pkgconfig未正确识别,可以显式启用use-pkgconfig特性,让Rust通过pkgconfig工具查找已安装的SDL库:

gate = { version = "0.10.0", features = ["use-pkgconfig"] }

同样需要确保已经安装了第一步中的两个开发库。

内容的提问来源于stack exchange,提问作者Nicolas Rey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 21:53:15