Search code examples
rustgstreamerrust-cargogstreamer-rs

use of undeclared crate or module '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`

Solution

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