使用未声明的 crate 或模块 ‘gst’

huangapple go评论113阅读模式
英文:

use of undeclared crate or module 'gst'

问题

  1. 我试图在 macOS(最新版本)上运行 [gstreamer crate][1],但出现了 `use of undeclared crate or module gst` 的错误。
  2. Cargo.toml
  3. [package]
  4. name = "gstreamerDemo"
  5. version = "0.1.0"
  6. edition = "2021"
  7. [dependencies]
  8. gstreamer = "0.20.2"
  9. [target.'cfg(target_os = "macos")'.dependencies]
  10. cocoa = "0.24"
  11. objc = "0.2.7"
  12. [1]: https://crates.io/crates/gstreamer#installation
  13. gstreamer 是使用二进制安装的(而不是使用 homebrew 安装)。
  14. pwd
  15. /Library/Frameworks/GStreamer.framework
  16. 使用 `cargo add gstreamer` 添加了依赖项。
  17. 代码:
  18. use gst::prelude::*;
  19. fn main() {
  20. gst::init().unwrap();
  21. }
  22. 错误信息:
  23. use gst::prelude::*;
  24. ^^^ 未声明的 crate 或模块 `gst`
英文:

I'm trying to run gstreamer crate on macOS (latest version)

but getting use of undeclared crate or module gst

Cargo.toml

  1. [package]
  2. name = "gstreamerDemo"
  3. version = "0.1.0"
  4. edition = "2021"
  5. [dependencies]
  6. gstreamer = "0.20.2"
  7. [target.'cfg(target_os = "macos")'.dependencies]
  8. cocoa = "0.24"
  9. objc = "0.2.7"

gstreamer is installed using the binaries (and not homebrew)

  1. pwd
  2. /Library/Frameworks/GStreamer.framework

added dependencies using cargo add gstreamer

code:

  1. use gst::prelude::*;
  2. fn main() {
  3. get::init().unwrap();
  4. }

error:

  1. use gst::prelude::*;
  2. ^^^ use of undeclared crate or module `gst`

答案1

得分: 3

无法在你的 Cargo.toml 中导入名为 gstreamer 的依赖,并在你的源代码中将其命名为 gst。但你可以通过以下方式重命名它,要么直接添加它并执行以下操作:

  1. cargo add gstreamer --rename gst

或者通过直接编辑 Cargo.toml 文件,删除 gstreamer = "0.20.2" 并将以下内容添加进去:

  1. [dependencies]
  2. gst = { version = "0.20.2", package = "gstreamer" }

当然,你也可以使用该 crate 的实际名称:

  1. 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

  1. cargo add gstreamer --rename gst

or by editing the Cargo.toml directly remove the gstreamer = "0.20.2" and add the following instead:

  1. [dependencies]
  2. gst = { version = "0.20.2", package = "gstreamer" }

Of course instead of renaming you could also use the crates actual name:

  1. use gstreamer::prelude::*;

huangapple
  • 本文由 发表于 2023年3月7日 14:25:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75658632.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定