Av1an icon indicating copy to clipboard operation
Av1an copied to clipboard

Unable to build on OSX

Open shaneday opened this issue 11 months ago • 4 comments

I'm trying to build av1an to run on an M2 Mac. I have the git repo cloned and when I run 'cargo build' it reports the following: (I've trimmed some unrelated warnings and the most of the massive cc command line. I can attach the log if needed)

Compiling av1an-core v0.4.1
[...](error: linking with `cc` failed: exit status: 1)
= note: ld: library 'vapoursynth' not found
... "cc" "-arch" "arm64" ... "/Users/shaneday/git/av1an/target/debug/deps/libvapoursynth-2fbdbd40c09d3a15.rlib" ... "/Users/shaneday/git/av1an/target/debug/deps/libvapoursynth_sys-314baf9d1a70c691.rlib" 
... "-lvapoursynth" "-lvapoursynth-script" ...

I've installed vapoursynth using 'brew install vapoursynth' and I can see the vapoursynth library files:

❯ ls /opt/homebrew/lib/libvapoursynth*
/opt/homebrew/lib/libvapoursynth-script.0.dylib
/opt/homebrew/lib/libvapoursynth-script.a
/opt/homebrew/lib/libvapoursynth-script.dylib
/opt/homebrew/lib/libvapoursynth.a
/opt/homebrew/lib/libvapoursynth.dylib

I have tried following ChatGPTs advice and adding to Cargo.toml:

[build]
rustflags = ["-L/opt/homebrew/lib"]

and also tried:

CARGO_LINKFLAGS="-L/opt/homebrew/lib" cargo build

without any luck.

Some guidance would be appreciated. I'm familiar with the command line and C programming, but I've never touched rust or cargo.

shaneday avatar Mar 01 '24 03:03 shaneday

I figure I'll drop the 'CARGO_LINKFLAGS="-L/opt/homebrew/lib" cargo build' log here just in case it is needed.

cargo-build.log

shaneday avatar Mar 01 '24 04:03 shaneday

same issue, same platform, on macOS 14.4.1, same error and same log output references missing vapoursynth library

joshurawr avatar Apr 09 '24 01:04 joshurawr

I found a workaround. The system "cc" on OSX doesn't include the path where homebrew installs libraries. So, it's up to the user to add that path when needed. You can do so as below. I don't recall where I got the CARGO_LINKFLAGS suggestion in my question. But either LIBRARY_PATH or RUSTFLAGS can do the trick.

brew install vapoursynth export LIBRARY_PATH="$LIBRARY_PATH:/opt/homebrew/lib" cargo build --release

or

brew install vapoursynth export RUSTFLAGS="-L /opt/homebrew/lib" cargo build --release

Install the new av1an binary

cp target/release/av1an /usr/local/bin/

Note: The above only works after commit "6db3966 Support ffmpeg 7.0", which isn't included in any tagged release yet. So, you'll need to be using the bleeding edge.

shaneday avatar Jun 04 '24 04:06 shaneday

FYI 0.4.3 was released ~24hrs ago and includes this change. So using nightly releases should no longer be necessary for this.

This could also be handled by Av1an, in the build.rs. ffmpeg-the-third already does this for the FFmpeg native libraries, it shouldn't be that difficult to do the same for the VS libs here. I'll take a look.

FreezyLemon avatar Aug 18 '24 18:08 FreezyLemon

The linked PR should resolve this problem. It's been merged into vapoursynth-rs but no new release has been made yet.

Until then, a temporary workaround would be using the git version by adding this to Cargo.toml (in root dir, not av1an or av1an-core):

[patch.crates-io]
vapoursynth = { git = "https://github.com/YaLTeR/vapoursynth-rs" }
vapoursynth-sys = { git = "https://github.com/YaLTeR/vapoursynth-rs" }

FreezyLemon avatar Aug 29 '24 09:08 FreezyLemon