My project depends on the ffmpeg-sys
crate which is configured to build statically, as follows:
[dependencies.ffmpeg-sys]
version = "3.4.1"
default-features = false
features = ["avcodec", "avformat", "swresample", "build", "static"]
My project consists of a single simple file:
extern crate ffmpeg_sys;
use ffmpeg_sys::av_register_all;
fn main() {
unsafe { av_register_all() };
println!("Hello, world!");
}
When compiling with cargo build
I get the following error:
Compiling sample v0.1.0 (file:///home/ec2-user/sample)
error: linking with 'cc' failed: exit code: 1 | = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L"[... elided for clarity ...]
In function 'sample::main::hbbb19855251826d6': /home/ec2-user/sample/src/main.rs:6: undefined reference to 'av_register_all' collect2: error: ld returned 1 exit status
The required static libraries, libavformat.a
and friends, are found in the target/build/debug
folder, showing that ffmpeg-sys
successfully compiled the libraries.
Here's the rustc
command that is failing:
Caused by: process didn't exit successfully: 'rustc --crate-name sample src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=250bf40eb277d05a -C extra-filename=-250bf40eb277d05a --out-dir /home/ec2-user/sample/target/debug/deps -C incremental=/home/ec2-user/sample/target/debug/incremental -L dependency=/home/ec2-user/sample/target/debug/deps --extern ffmpeg_sys=/home/ec2-user/sample/target/debug/deps/libffmpeg_sys-fa3ff87f80f2d27e.rlib -L native=/home/ec2-user/sample/target/debug/build/ffmpeg-sys-0b3c813f29a9a20e/out/dist/lib' (exit code: 1)
libffmpeg_sys-fa3ff87f80f2d27e.rlib
is 207M and I assume therefore contains all the statically compiled ffmpeg code.
This only happens when I build on an Amazon Linux instance. Compiling on my regular Fedora 28 desktop results in a working binary.
How would I go about figuring out the root cause of this error?
target/debug/build/<pkg>/output
– attdonagit
by cargo. – Tim