larksuite / rsmpeg

A Rust crate that exposes FFmpeg's power as much as possible.
https://docs.rs/rsmpeg/latest/rsmpeg/
MIT License
678 stars 41 forks source link

Compilation error #67

Closed aegroto closed 3 years ago

aegroto commented 3 years ago

Hello,

The last version of rsmpeg (0.6.0) doesn't seem to compile:


error[E0425]: cannot find function `av_gcd_q` in module `ffi`
    --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/rsmpeg-0.6.0/src/avutil/rational.rs:65:19
     |
65   |     unsafe { ffi::av_gcd_q(a, b, max_den, def) }
     |                   ^^^^^^^^
     |
    ::: /home/lorenzo/Scrivania/Varie/repo/remotia/target/debug/build/rusty_ffmpeg-f322e92cb20dcce1/out/binding.rs:6392:5
     |
6392 |     pub fn av_add_q(b: AVRational, c: AVRational) -> AVRational;
     |     ------------------------------------------------------------ similarly named function `av_add_q` defined here
     |
help: a function with a similar name exists
     |
65   |     unsafe { ffi::av_add_q(a, b, max_den, def) }
     |                   ~~~~~~~~
help: consider importing this function
     |
1    | use crate::avutil::av_gcd_q;error[E0425]: cannot find function `av_gcd_q` in module `ffi`
    --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/rsmpeg-0.6.0/src/avutil/rational.rs:65:19
     |
65   |     unsafe { ffi::av_gcd_q(a, b, max_den, def) }
     |                   ^^^^^^^^
     |
    ::: /home/lorenzo/Scrivania/Varie/repo/remotia/target/debug/build/rusty_ffmpeg-f322e92cb20dcce1/out/binding.rs:6392:5
     |
6392 |     pub fn av_add_q(b: AVRational, c: AVRational) -> AVRational;
     |     ------------------------------------------------------------ similarly named function `av_add_q` defined here
     |
help: a function with a similar name exists
     |
65   |     unsafe { ffi::av_add_q(a, b, max_den, def) }
     |                   ~~~~~~~~
help: consider importing this function
     |
1    | use crate::avutil::av_gcd_q;
     |
     |

I've tried downgrading the ffmpeg release to 4.3 but it doesn't seem to work.

rustc --version output is:

rustc 1.56.1 (59eed8a2a 2021-11-01)

ldm0 commented 3 years ago

Hm, this is strange. Have you tried cargo clean?

aegroto commented 3 years ago

Yes, I did. You may find the source code here: https://github.com/aegroto/remotia/tree/rsmpeg

I've built ffmpeg using the suggested linux script, may have I missed some necessary environment configuration?

ldm0 commented 3 years ago

I've built ffmpeg using the suggested linux script, may have I missed some necessary environment configuration?

I tried but cannot reproduce the problem.

The error is telling us that av_gcd_q is not found. Since rsmpeg's dep(rusty_ffmpeg) generates bindings at compile time, the error indicates that the header files of FFmpeg doesn't contain the symbol av_gcd_q.

From the change log of FFmpeg , av_gcd_q is added recently:

2020-05-23 - 6b65c4ec54 - lavu 56.47.100 - rational.h
  Add av_gcd_q().

Since 2020-6-15 is the release date of FFmpeg 4.3, FFmpeg with no av_gcd_q's version is less than 4.3. But the linux script clones and builds FFmpeg 4.4, which shouldn't leads to the problem.

You can check if there is a prebulit FFmpeg(< 4.3) installed on your local machine(when rusty_ffmpeg doesn't see the developer-provided FFmpeg, it will search it in the system dir), and check if you provided the correct absolute path of the script-built FFmpeg's pkg-config dir via FFMPEG_PKG_CONFIG_PATH.

Feel free to comment more if the problem persists. @aegroto

ldm0 commented 3 years ago

BTW, ci of this repo is relatively complete, which makes me pretty confident with the usability of this crate(:-P). You can check the build_static_and_test_ubuntu section of https://github.com/larksuite/rsmpeg/blob/master/.github/workflows/ci.yml for a canonical build and test procedure.

aegroto commented 3 years ago

Thanks for the extensive response! I guess the problem was some sort of error while setting the FFMPEG_PKG_CONFIG_PATH.