MacOs M1 Library not loaded: @rpath/libgobject-2.0.0.dylib
hi, i also had the same problem.
The cargo build
succeeded.
However, cargo run
the following error occurred
Library not loaded: @rpath/libgobject-2.0.0.dylib
Finished dev [unoptimized + debuginfo] target(s) in 18.98s
Running `target/debug/rust_gstream_rtmp`
dyld[21579]: Library not loaded: @rpath/libgobject-2.0.0.dylib
Referenced from: <49FDC051-D944-3BFE-9772-A24BF847CA6C> /Users/ken/codes/rust_project/gstreamer_test_1/rust_gstream_rtmp/target/debug/rust_gstream_rtmp
Reason: tried: '/System/Volumes/Preboot/Cryptexes/OS@rpath/libgobject-2.0.0.dylib' (no such file), '/Users/ken/codes/rust_project/gstreamer_test_1/rust_gstream_rtmp/target/debug/deps/libgobject-2.0.0.dylib' (no such file), '/Users/ken/codes/rust_project/gstreamer_test_1/rust_gstream_rtmp/target/debug/libgobject-2.0.0.dylib' (no such file), '/Users/ken/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libgobject-2.0.0.dylib' (no such file), '/Users/ken/.rustup/toolchains/stable-aarch64-apple-darwin/lib/libgobject-2.0.0.dylib' (no such file), '/Users/ken/lib/libgobject-2.0.0.dylib' (no such file), '/usr/local/lib/libgobject-2.0.0.dylib' (no such file), '/usr/lib/libgobject-2.0.0.dylib' (no such file, not in dyld cache)
[1] 21579 abort cargo run
I'm pretty sure I didn't install from brew
. all installation packages are from official.
We recommend using the official GStreamer binaries over Homebrew, especially as GStreamer in Homebrew is [currently broken]
Environments : M1 Mac
~/.zshrc
export PKG_CONFIG_PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
export PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/bin${PATH:+:$PATH}"
GStreamer Version
❯ gst-launch-1.0 --version
gst-launch-1.0 version 1.21.1
GStreamer 1.21.1
Unknown package origin
Rust Version
❯ rustup -V
rustup 1.25.1 (bb60b1e89 2022-07-12)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.65.0 (897e37553 2022-11-02)`
cargo.toml
[package]
name = "rust_gstream_rtmp"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
gstreamer = "0.19.2"
[target.'cfg(target_os = "macos")'.dependencies]
cocoa = "0.24"
main.rs
use gstreamer::prelude::*;
mod tutorials_common;
fn tutorial_basic_1() {
// Initialize GStreamer
gstreamer::init().unwrap();
// Build the pipeline
let uri =
"https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm";
let pipeline = gstreamer::parse_launch(&format!("playbin uri={}", uri)).unwrap();
// Start playing
pipeline
.set_state(gstreamer::State::Playing)
.expect("Unable to set the pipeline to the `Playing` state");
// Wait until error or EOS
let bus = pipeline.bus().unwrap();
for msg in bus.iter_timed(gstreamer::ClockTime::NONE) {
use gstreamer::MessageView;
match msg.view() {
MessageView::Eos(..) => break,
MessageView::Error(err) => {
println!(
"Error from {:?}: {} ({:?})",
err.src().map(|s| s.path_string()),
err.error(),
err.debug()
);
break;
}
_ => (),
}
}
// Shutdown pipeline
pipeline
.set_state(gstreamer::State::Null)
.expect("Unable to set the pipeline to the `Null` state");
}
fn main() {
// tutorials_common::run is only required to set up the application environment on macOS
// (but not necessary in normal Cocoa applications where this is set up automatically)
tutorials_common::run(tutorial_basic_1);
}