Open bbonvi opened 1 year ago
Hi @bbonvi. These symbols are from transitive dependencies (i.e. dependencies of FFmpeg). It appears that the linker:
I'm not an OSX expert, so I'm not really sure how to fix this problem. On Linux, I'd suggest setting the LD_LIBRARY_PATH
environment variable to the path where these dependencies are located. But I don't know if this variable works on OSX as well.
I ran into the same problem but for x86_64
and was able make a little bit of progress by adding this .cargo/confog.toml
:
[env]
FFMPEG_INCLUDE_DIR = { value = "ffmpeg-5.1-macOS-gpl-lite/include/", relative = true} # ffmpeg folder is in the root of my project
FFMPEG_LIB_DIR = { value = "ffmpeg-5.1-macOS-gpl-lite/lib/", relative = true }
FFMPEG_STATIC = "1"
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
[target.aarch64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
I downloaded the ffmpeg files from here: https://sourceforge.net/projects/avbuild/files/macOS/
I can now build with cargo build --release
but when I try to run the executable I get this error:
$ ./target/release/ac-ffmpeg-test
dyld[55693]: symbol not found in flat namespace (_kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms)
[1] 55693 abort ./target/release/ac-ffmpeg-test
Not sure what to try next but maybe this helps.
Facing the same issue.
The weird part is dynamic linking works ( FFMPEG_STATIC
flag is not set ), but trying to link it statically throws this error. Is this behaviour expected @operutka
Is there a way to debug which dependency is causing these problems?
I found similar answers where we may need to pass in some extra framework
parameters to the linker. Do you think it could work? How do I try it out?
I was able to get it to work by compiling my own version of ffmpeg and using it and updating the ac-ffmpeg/build.rs
script to link some more dependencies required. Here are the updates
// Add paths to some more places the compiler needs to search for dependencies
println!("cargo:rustc-link-search=native=/opt/homebrew/opt/zlib/lib/");
println!("cargo:rustc-link-search=native=/opt/homebrew/opt/x264/lib/");
println!("cargo:rustc-link-search=native=/opt/homebrew/opt/bzip2/lib/");
// Add MacOS based frameworks in the compilation command
println!("cargo:rustc-link-lib=framework=CoreServices");
println!("cargo:rustc-link-lib=framework=CoreGraphics");
println!("cargo:rustc-link-lib=framework=CoreText");
println!("cargo:rustc-link-lib=framework=CoreFoundation");
println!("cargo:rustc-link-lib=framework=AudioUnit");
println!("cargo:rustc-link-lib=framework=AudioToolbox");
println!("cargo:rustc-link-lib=framework=CoreAudio");
println!("cargo:rustc-link-lib=framework=Security");
println!("cargo:rustc-link-lib=framework=VideoToolbox");
// Link some more dependencies required
link("z", ffmpeg_link_mode);
link("x264", ffmpeg_link_mode);
link("bz2", ffmpeg_link_mode);
// current code continues...
link("avcodec", ffmpeg_link_mode);
link("avformat", ffmpeg_link_mode);
link("avutil", ffmpeg_link_mode);
link("swresample", ffmpeg_link_mode);
link("swscale", ffmpeg_link_mode);
Do you think these need to be submitted as a patch ( with path changes ) or is there some other location I can store the extra dependencies ( e.g zlib, bz2 ) so that they are automatically compiled ? @operutka
@Pranav2612000 this library really isn't the place to link these libs. These libraries are transitive dependencies (i.e. they are dependencies of the FFmpeg libs) and they depend on the FFmpeg configuration.
If your linker isn't able to resolve the symbols/dependencies automatically, you need to link them in the final application (i.e. the binary using this crate).
Hello!
I'm having trouble compiling the library under Apple M1. I have ffmpeg version 5.1.2. Tried different installations: with shared and static libs. Still have this error. Maybe you can kick me in the right direction?
full_log.txt