How To Create .dylibs For Mac

About

Plugins and dylibs for Unity3D in Mac OSX. Discussion in 'Editor & General Support' started by PMY-Archon, Nov 18, 2013. Joined: Oct 23, 2013 Posts: 1. Hi, I wrote a simple plugin for Unity3D which works perfectly in Windows and Linux. But the real problem is to make it work under Mac OSX. I followed these guidelines.

Mac OS X introduced an innovative and very useful way to package applications : app bundles.While their design has all that is needed to ease distribution of resources and frameworks, itseems like dynamic libraries (.dylib) are very complicated to distribute. Sure, applications developedspecifically for OS X won't make use of them, however applications ported from Linux or other Unices may havedependencies that will only compile as dylibs. By default, there exists no mechanism to bundle them but some command-line utilities provided by Apple - however it turns out that for a single program it is often necessary to issue dozens of commands! This often leads each porter to develop their own 'home solution' wich are often hacky, poorly portable and/or nonoptimal.

dylibbundler is a small command-line programs that aims to make bundling .dylibs as easy as possible.It automatically determines which dylibs are needed by your program, copies these libraries inside the app bundle, and fixes both them and the executable to be ready for distribution.. all this with a single command on the teminal! It will also work if your program uses plug-ins that have dependencies too.

It usually involves 2 actions :

  • Creating a directory (by default called libs) that can be placed inside the Contents folder of the app bundle.
  • Fixing the executable file so that it is aware of the new location of its dependencies.

Installation

In the terminal, cd to the main directory of dylibbundler and type 'make'. You can install with 'sudo make install'.

Feedback / Contact

You can contact me here on github, for instance by creating a ticket or pull request

Using dylibbundler on the terminal

Here is a list of flags you can pass to dylibbundler on the terminal.

-h, --help

displays a summary of options

-x, --fix-file (executable or plug-in filepath)

Fixes given executable or plug-in file (a .dylib can work too. anything on which `otool -L` works is accepted by `-x`). Dylibbundler will walk through the dependencies of the specified file to build a dependency list. It will also fix the said files' dependencies so that it expects to find the libraries relative to itself (e.g. in the app bundle) instead of at an absolute path (e.g. /usr/local/lib). To pass multiple files to fix, simply specify multiple `-x` flags.

-b, --bundle-deps

Copies libaries to a local directory, fixes their internal name so that they are aware of their new location,fixes dependencies where bundled libraries depend on each other. If this option is not passed, no libraries will be prepared for distribution.

-i, --ignore (path)

Dylibs in (path) will be ignored. By default, dylibbundler will ignore libraries installed in /usr/lib since they are assumed to be present by default on all OS X installations.(It is usually recommend not to install additional stuff in /usr/, always use /usr/local/ or another prefix to avoid confusion between system libs and libs you added yourself)

How to create .dylibs for mac os

-d, --dest-dir (directory)

Sets the name of the directory in wich distribution-ready dylibs will be placed, relative to the current working directory. (Default is ./libs) For an app bundle, it is often conveniant to set it to something like ./MyApp.app/Contents/libs.

-p, --install-path (libraries install path)

Sets the 'inner' installation path of libraries, usually inside the bundle and relative to executable. (Default is @executable_path/./libs/, which points to a directory named libs inside the Contents directory of the bundle.)

-s, --search-path (search path)

Check for libraries in the specified path

The difference between -d and -p is that -d is the location dylibbundler will put files at, while -p is the location where the libraries will be expected to be found when you launch the app. Both are often related.

-of, --overwrite-files

When copying libraries to the output directory, allow overwriting files when one with the same name already exists.

-od, --overwrite-dir

If the output directory already exists, completely erase its current content before adding anything to it. (This option implies --create-dir)

-cd, --create-dir

If the output directory does not exist, create it.

A command may look like% dylibbundler -od -b -x ./HelloWorld.app/Contents/MacOS/helloworld -d ./HelloWorld.app/Contents/libs/

If you want to create a universal binary by merging toghether two builds from PPC and Intel machines, you can ease it up by putting the ppc and intel libs in different directories, then to create the universal binary you only have to lipo the executable.

How to Make Handbrake Libdvdcss Workable on Mac OS X El Capitan or Later

If your MacBook or iMac is running on Mac OS X El Capitan or later version and you need to make libdvdcss workable on Mac OS X 10.11 for your Handbrake DVD ripping, you are suggested to prepare yourself mentally. The Handbrake for Mac OS X 10.11 doesn't run as smoothly as the one abovementioned. Modbus rtu driver for mac.

Case 1: El Capitan apparently broke Handbrake ripping copy-protected DVDs. Any clue what to do?

Solutions:
1) Disable SIP and reinstall libdvdcss on Mac El Capitan. FIY: SIP means System Integrity Protection, the new security system for OS X El Capitan.
2) Install a copy via homebrew ( a package manager).
3) Move software library to /usr/local/lib instead, which is not protected by SIP.

How to move libdvdcss file to /usr/local/lib?
• Create a new Finder window
• Go to /Library/SystemMigration/History/ through cmd-shift-G (<--copy the path from here also allowed) and manually proceed on inside Migration-some-gibberish/QuarantineRoot/usr
• Copy the libdvdcss.2.dylib file (Cmd-C)
• Apply cmd-shift-G to /usr/local/lib (no copy remember!)
• Take use of cmd-opt-V to move it (not copy) it to this location
• It will ask for your password and should then move it.

Case 2: Current libdvdcss version is 2.8.1 BUT won't install on OS X El Capitan unless it has been installed before upgrading. The problem seems to be that El Capitan does not allow the creation of the necessary folders in usr. If you installed it BEFORE updating to El Capitan then there is no problem. I tried to disable rootless but still no luck

Solutions:
1) Downgrade your El Capitan to Mac OS X Yosemite first and then download & install libdvdcss and OSXfuse on Yosemite before upgrading to El Capitan.
2) Generally, /usr/local can't be found on fresh installs of OS X 10.5 to 10.10. When you update operating system from Yosemite (no /usr/local directory) to El Capitan, /usr/local is generated automatically. If not, there might be something wrong with the El Capitan installer or your system.

The way to fix libdvdcss won't install problem is temporarily disable rootless, create the directory, make sure the 'restricted' flag is not set, and re-enable rootless.

More Handbrake Not Working Tips
▼ Handbrake no source found
▼ Fix Handbrake VLC2.0 issue
▼ Handbrake no title found
▼ Handbrake reading error
▼ Handbrake won't rip DVD
▼ Handbrake video/audio out-sync