skip to Main Content

I try to make macOS GUI application with ffmpeg.
On project settings -> General -> Frameworks,Libraries…, I added the ffmpeg lib files
/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/lib/libavutil.57.28.100.dylib.
I also add lib search path of /opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/lib

I still get error : Library not found for -lavutil.57.58.100.

I like to get more detail about error.
I think these possibility

  • not valid arm64 format.
  • linker expect x64 and arm64 binary. But the file has arm64 only.
  • Dependency of dylib is missing.

If someone knows solution or detail about this error, please let me know.

That file exist and valid arm64 Mach-O file.
file libavutil.57.28.100.dylib
libavutil.57.28.100.dylib: Mach-O 64-bit dynamically linked shared library arm64

2

Answers


  1. Chosen as BEST ANSWER

    Xcode does not add library search path. I add -L/opt/homebrew/Cellar/ffmpeg/5.1-with-options_2/lib on "Other Linker Flags"


  2. Some tips that will help you to troubleshoot this issue.

    Firstly, lldb expects an arm64 version of the lib if your main executable’s architecture is arm64, a fat-universal version of the lib if your main executable’s architecture is fat-universal.
    So please check the main executable’s architecture inside YOURAPP.app/Contents/MacOS. I’m taking IINA video player as an example:

    lipo -i /Applications/IINA.app/Contents/MacOS/IINA
    

    Secondly, it’s not good to refer to a brew version of the binary. If the library’s version on another machine mismatches with yours, your app will crash. It’s ok that you copy the dylib file and copy it into your Xcode project. Then you can add the dylib file to the Frameworks, libraries, and Embedded Content section in Xcode. The below image shows an example of integrating ffmpeg libs into your project.
    enter image description here

    Alternatively, the ffmpeg-kit package is your friend. I have a simple showcase for you: Github

    Finally, if you insist on using the brew version, please disable checking on code-signing for external libs: Project Settings > Signing & Capabilities > Hardened Runtime > Runtime Exceptions > Diable Library Validation

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search