macospackaging

What is the simplest way to distribute an app depending on a few .dylib(s) on Mac (would zipping the .dylib(s) work)?


I built a simple app using Crystal on a Mac, and it appears to depend upon two libraries (.dylib).

What is the simplest way to distribute that app (would zipping the .dylib(s) along with the executable in a given directory work), or do I have to use a tool like install_name_tool to rewrite the path to the libraries?

In other words, if the required libraries are in the same directory than the executable, will the executable find them or is the path to libraries hard-coded in a Mac application?

otool -L ./bin/hello: yields:

./bin/hello:
    /opt/homebrew/opt/bdw-gc/lib/libgc.1.dylib (compatibility version 7.0.0, current version 7.1.0)
    /opt/homebrew/opt/libevent/lib/libevent-2.1.7.dylib (compatibility version 8.0.0, current version 8.1.0)
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)

Solution

  • Yes, you need to use install_name_tool to change the path that the app searches

    To make it easier, you can use macdylibdundler to perform all the necessary commands