Crate uses pkg-config to search for lib, is there an easier way?

I'm trying to add to my project. I get this error when I add it as a dependency to my project:

thread 'main' panicked at 'calledResult::unwrap()on anErrvalue: Failure { command: "\"pkg-config\" \"--libs\" \"--cflags\" \"libavformat\"", output: Output { status: ExitStatus(ExitStatus(256)), stdout: "", stderr: "Package libavformat was not found in the pkg-config search path.\nPerhaps you should add the directory containinglibavformat.pc'\nto the PKG_CONFIG_PATH environment variable\nNo package 'libavformat' found\n" } }',`

I understand what the problem is, I should have libavformat in my system. But is there an easier way? Maybe to specify the place where they are manually? I do not want to install them in my system:

I'm asking this mainly because I want to use this crate for different architectures, so there are different for each architecture.

You can have it download ffmpeg and statically link it with:

ffmpeg-sys = { version = "4", features = ["build"] }

See here for more.

hmmmm ok. Turns out that ffmpeg is very hard to build so I already have them built, I only need to link with the right one for the right architecture.

I've been reading about build scripts ( but it isn't clear how I can simply link against some .a from ffmpeg for the right architecture that is being built.

Do you know how?

Looks like in the lib you linked to me, there's this:

if statik && is_static_available(val, &lib.include_paths) {
    println!("cargo:rustc-link-lib=static={}", val);
} else {
    println!("cargo:rustc-link-lib={}", val);

fn is_static_available(lib: &str, dirs: &[PathBuf]) -> bool {
let libname = format!("lib{}.a", lib);
let has = dirs.iter().map(|d| d.as_path())
.any(|dir| dir.join(&libname).exists());
if !has {
println!("cargo:warning=static {} not found", libname);

But it only prints things. How can I use it to actually link things to the right architecture?

A cargo script informs the compiler what to link to by printing things. If you are missing some feature, I recommend opening an issue on the ffmpeg-sys repository.

meh's ffmpeg version is abandoned, and will not work with ffmpeg v4 correctly.

Use the up-to-date fork:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.