Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds proper dynamic linking #69

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

lattice0
Copy link

dynamic linking was trying to link to a single file

this adds dynamic linking to the various .so files

tested and worked

@lattice0
Copy link
Author

I also added multi architecture build. Sometimes when you want to build an Android APK you need a way of passing a single directory with .so files for every architecture.

Now with

FFMPEG_MULTI_ARCH_BUILD=1

FFMPEG_LIBS_DIR will be used as a base, and it will do like this

FFMPEG_LIBS_DIR/{target_os}/target_arch/

and it will search for the libs in this folder.

@ldm0 ldm0 self-requested a review June 23, 2022 05:34
@lattice0
Copy link
Author

would be nice to have this merged :)

@niuhuan
Copy link

niuhuan commented Nov 13, 2022

How to build for android and iOS ?

I had bulit ffmpeg-kit ,

and add this to cargo.toml
rusty_ffmpeg = { git = "https://github.com/lattice0/rusty_ffmpeg.git", branch = "master" }

then run cargo ndk build
FFMPEG_PKG_CONFIG_PATH=/Volumes/DATA/Projects/ffmpeg-kit/prebuilt/android-arm64/ffmpeg/lib/pkgconfig cargo ndk -t arm64-v8a build

error: failed to run custom build command for `rusty_ffmpeg v0.10.0+ffmpeg.5.1`

Caused by:
  process didn't exit successfully: `/Volumes/DATA/Projects/bili-cli-rs/target/debug/build/rusty_ffmpeg-e44e608450ec302b/build-script-build` (exit status: 101)

  --- stderr
  thread 'main' panicked at 'avcodec not found!', /Volumes/DATA/Runtimes/.cargo/registry/src/github.com-1ecc6299db9ec823/rusty_ffmpeg-0.10.0+ffmpeg.5.1/build.rs:247:37
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
✗ ls /Volumes/DATA/Projects/ffmpeg-kit/prebuilt/android-arm64/ffmpeg/lib/
libavcodec.so    libavfilter.so   libavutil.so     libswscale.so
libavdevice.so   libavformat.so   libswresample.so pkgconfig

@emilazy
Copy link

emilazy commented Jul 22, 2024

It would be great to be able to properly dynamically link on Unix platforms. If me rebasing this PR would make any difference to getting it merged let me know.

if let Some(f) = file_name {
println!("cargo:rustc-link-lib=dylib={}", f);
}
}
Copy link

@SimonRacaud SimonRacaud Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing rustc-link-search ?
++ println!("cargo:rustc-link-search=native={}", ffmpeg_dll_path);

@SimonRacaud
Copy link

SimonRacaud commented Aug 19, 2024

I needed to link ffmpeg dlls directly to the project (my dev PC must be offline -> military project), and I can confirm that in single architecture build mode, it works (with a little alteration).
For those in the same situation than me, I used the following env vars to make it works:

# (In config.toml)

[env]
# To generate the binding:
FFMPEG_INCLUDE_DIR = { value = '..\dependencies\win\ffmpeg_msvc\include', relative = true, force = true }
# To indicate location of avcodec, avutil, swresample, (..) => `.dll` AND `.lib`
FFMPEG_DLL_PATH = { value = '..\dependencies\win\ffmpeg_msvc\bin\', relative = true, force = true }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants