Solved 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 fileINCLUDEPATH +=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 fileslibavcodec.58.dylib libavdevice.58.dylib libavfilter.7.dylib libavformat.58.dylib libavutil.56.dylib libpostproc.55.dylib libswresample.3.dylib libswscale.5.dylib
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.
-
Hi,
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?:
DYLD_LIBRARY_PATH
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?
-
You should do that in the Run part of the Project panel. It's not a qmake variable.