dylib: Library not found:
....
Reason: image not found
You can fix this by doing the following:
- Figure out what libraries are dynamically linked to the process using:
- otool -L process_name
- Note: You may have to do this for each dynamic library as well and change the paths for the libraries in the dynamic libraries you are linking into your process. As you can tell this can result in a lot of changes but if you want to move stuff to a new location, it's your best option, as compared to building from source all the required libraries and process.
- Change the path of those dynamic libraries using:
- install_name_tool -change old new process_name
Reference: [http://stackoverflow.com/questions/1937232/linking-to-a-dynamic-library-on-a-mac-with-full-path]
UPDATE:
While relocating the library paths for the library I was working with I came up with a pattern of steps to fix this:
Run: otool -L .dylid For example:
otool -L libintl.8.dylibThen notice that we want to change /opt/local/lib/ to /mypath/lib/. To do that you need to run:
libintl.8.dylib:
/opt/local/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.1.0)
/opt/local/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 635.19.0)
install_name_tool -change /opt/local/lib/libintl.8.dylib /mypath/lib/libintl.8.dylib /path/to/libintl.8.dylib
This works great until you run into this error:
install_name_tool: changing install names can't be redone for: /mypath/lib/libintl.8.dylib (for architecture i386) because larger updated load commands do not fit (the program must be relinked)[Reference: http://annoyingtechnicaldetails.wordpress.com/2007/04/18/install_name_tool-changing-install-names-cant-be-redone-for-for-architecture-ppc-because-larger-updated-load-commands-do-not-fit-the-program-must-be-relinked/]
To fix this you need to recompile the library with options to enable the relocation of the library paths. If the library uses configure then chances are you can add these options to the configure to make it build such that the path for the libraries are relocatable:
- Add this to your LDFLAGS=-headerpad_max_install_names
- And if available use the configure options: --disable-rpath --enable-relocatable Reference[http://www.manpagez.com/info/relocatable/]
- So for example here is an example for libiconv:
./configure --prefix=/mypath/ --disable-rpath --enable-relocatable LDFLAGS=-headerpad_max_install_names