login about faq

We are implementing Chilkat cocoa library for ftp. All works well if we put the library in "/usr/local/lib/". But when we try to run without it it crashes with error

dyld: Library not loaded: /usr/local/lib/libchilkatCocoaDyn.dylib

Referenced from: /Users/abc/Library/Developer/Xcode/DerivedData/xyz/Build/Products/Debug/something.app/Contents/MacOS/

Reason: image not found

We know its common issue for dynamic libraries. Can you please help us with this? How should i bundle libchilkatCocoaDyn.dylib within the app?

asked Oct 04 '13 at 10:56

chilkat's gravatar image

chilkat ♦♦

edited Oct 04 '13 at 11:02

On the Mac a dynamic library (dylib) has an "install name". The install name is a path baked into the dynamic library that says where to find the library at runtime. When you link against the dylib this path is saved in your binary so that your binary can find the dylib at runtime.

You can see the install name of a dylib by using otool. For example:

$ otool -D libchilkatCocoaDyn.dylib

This means that unless you set the DYLD_LIBRARY_PATH environment variable to allow the runtime linker find the dylib, the dylib must be placed in the exact location as specified by the install name.

However, you can change the install name of a dylib by using the install_name_tool utility. You can also use the @loader_path keyword to make it relative to an install directory.

I would recommend becoming familiar with the install_name_tool command and it's various options. For example, this command changes the install name of libchilkatCocoaDyn.dylib to be relative to the location of the binary using it:

$ install_name_tool -id "@loader_path/dylibs/libchilkatCocoaDyn.dylib" libchilkatCocoaDyn.dylib


answered Oct 04 '13 at 11:24

chilkat's gravatar image

chilkat ♦♦

Also, instead of @loader_path, investigate using @rpath instead.

(Oct 04 '13 at 11:27) chilkat ♦♦

Google "install_name_tool" for more information..

(Oct 04 '13 at 11:28) chilkat ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Oct 04 '13 at 10:56

Seen: 23,113 times

Last updated: Oct 04 '13 at 11:28

powered by OSQA