Important: Please read the Qt Code of Conduct -

How to find dynamically linked libraries on a Mac?

  • I'm writing a program that links to a third party library. I've already got it working on Windows and am now trying to figure out how to get it to work for Mac. I'm not very familiar with Mac programming.

    Anyhow, I've put my precompiled libraries under $$PWD/thirdParty and added them to my .pro file

    INCLUDEPATH +=thirdParty/ffmpeg/include
    win32 {
    LIBS += -L$$PWD/thirdParty/ffmpeg/win32/lib
    LIBS += -lavcodec -lavformat -lavutil -lswscale -lswresample
    macx {
    #MacOs specific stuff
    LIBS += -L$$PWD/thirdParty/ffmpeg/macos/bin
    LIBS += -lavcodec.58 -lavformat.58 -lavutil.56 -lswscale.5 -lswresample.3

    My thirdParty/ffmpeg/macos/bin directory contains the files


    At the moment, I can link but I cannot run in the debugger. The program crashes:

    1 __abort_with_payload                                                                                                   (x86_64) /usr/lib/dyld  0x100616456 
    2 abort_with_payload_wrapper_internal                                                                                    (x86_64) /usr/lib/dyld  0x100615c4d 
    3 abort_with_payload                                                                                                     (x86_64) /usr/lib/dyld  0x100615c7f 
    4 dyld::halt(const char *)                                                                                               (x86_64) /usr/lib/dyld  0x1005d3aea 
    5 dyld::_main(macho_header const *, unsigned long, int, const char * *, const char * *, const char * *, unsigned long *) (x86_64) /usr/lib/dyld  0x1005d69dd 
    6 dyldbootstrap::start(macho_header const *, int, const char * *, long, macho_header const *, unsigned long *)           (x86_64) /usr/lib/dyld  0x1005d04f6 
    7 _dyld_start                                                                                                            (x86_64) /usr/lib/dyld  0x1005d0036 

    On Windows, copying the relevant .dlls into the debug build directory allowed me to run, but doing the same with the .dylib files on mac does not help.

  • Lifetime Qt Champion


    You can use the DYLD_LIBRARY_PATH environment variable to add folders to the dynamic loader search paths.

  • @SGaist said in How to find dynamically linked libraries on a Mac?:


    I added

    DYLD_LIBRARY_PATH += -L$$PWD/thirdParty/ffmpeg/macos/bin

    but that didn't change the error I was getting.

    Also, that might help run in the debugger, but I also need this to run from the command line when its finally ready to deploy. Would you know how to load the libraries in that case?

  • Lifetime Qt Champion

    You should do that in the Run part of the Project panel. It's not a qmake variable.

Log in to reply