英文:
use of undeclared crate or module 'gst'
问题
我试图在 macOS(最新版本)上运行 [gstreamer crate][1],但出现了 `use of undeclared crate or module gst` 的错误。
Cargo.toml
[package]
name = "gstreamerDemo"
version = "0.1.0"
edition = "2021"
[dependencies]
gstreamer = "0.20.2"
[target.'cfg(target_os = "macos")'.dependencies]
cocoa = "0.24"
objc = "0.2.7"
[1]: https://crates.io/crates/gstreamer#installation
gstreamer 是使用二进制安装的(而不是使用 homebrew 安装)。
❯ pwd
/Library/Frameworks/GStreamer.framework
使用 `cargo add gstreamer` 添加了依赖项。
代码:
use gst::prelude::*;
fn main() {
gst::init().unwrap();
}
错误信息:
use gst::prelude::*;
^^^ 未声明的 crate 或模块 `gst`
英文:
I'm trying to run gstreamer crate on macOS (latest version)
but getting use of undeclared crate or module gst
Cargo.toml
[package]
name = "gstreamerDemo"
version = "0.1.0"
edition = "2021"
[dependencies]
gstreamer = "0.20.2"
[target.'cfg(target_os = "macos")'.dependencies]
cocoa = "0.24"
objc = "0.2.7"
gstreamer is installed using the binaries (and not homebrew)
❯ pwd
/Library/Frameworks/GStreamer.framework
added dependencies using cargo add gstreamer
code:
use gst::prelude::*;
fn main() {
get::init().unwrap();
}
error:
use gst::prelude::*;
^^^ use of undeclared crate or module `gst`
答案1
得分: 3
无法在你的 Cargo.toml
中导入名为 gstreamer
的依赖,并在你的源代码中将其命名为 gst
。但你可以通过以下方式重命名它,要么直接添加它并执行以下操作:
cargo add gstreamer --rename gst
或者通过直接编辑 Cargo.toml
文件,删除 gstreamer = "0.20.2"
并将以下内容添加进去:
[dependencies]
gst = { version = "0.20.2", package = "gstreamer" }
当然,你也可以使用该 crate 的实际名称:
use gstreamer::prelude::*;
英文:
You cannot import a dependency gstreamer
in your Cargo.toml
and use it as gst
in your source code. You could however rename it, either by directly adding it with
cargo add gstreamer --rename gst
or by editing the Cargo.toml
directly remove the gstreamer = "0.20.2"
and add the following instead:
[dependencies]
gst = { version = "0.20.2", package = "gstreamer" }
Of course instead of renaming you could also use the crates actual name:
use gstreamer::prelude::*;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论