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

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

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::*;

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:

确定