> On Jul 1, 2015, at 7:55 PM, Graham Cox <graham....@bigpond.com> wrote:
> 
> Hi all,
> 
> I’m developing an app that includes a .dylib within its own resources. For 
> convenience I’m locating this in the /Frameworks subdirectory. I added a File 
> Copy to the Build Phases to copy the library there, and I confirm it’s being 
> done in both debug and release builds. I also added the 
> @executable_path/../Frameworks search path in the Runpath Search Paths build 
> setting.
> 
> This was working fine until just now. Suddenly, it’s throwing a runtime error:
> 
> dyld: Library not loaded: /usr/local/lib/MyLib.dylib
>  Referenced from: 
> /Users/grahamcox/Library/Developer/Xcode/DerivedData/Graphplot-bmgxcdcnhapazbfdwmjklsckwjon/Build/Products/Debug/Graphplot.app/Contents/MacOS/Graphplot
>  Reason: image not found
> 
> This suggests it’s searching in /usr/local/lib/ for the library, not the 
> /Frameworks relative path.

Check the install name of the copy of MyLib.dylib that you are linking against.

The location to search for a library is chosen at build time. The linked-to 
library contains an "install name" which is the location where the library will 
be found at runtime. The built executable records the install name of 
everything it links to. The install name of the library is in turn specified 
when the library itself is built.

Run `otool -lv MyLib.dylib` and look for the LC_ID_DYLIB load command to see 
the library's install name. My guess is that MyLib.dylib has a default install 
name of /usr/local/lib/MyLib.dylib. If you want to load MyLib.dylib relative to 
a Runpath Search Path then MyLib.dylib should be built with an install name of 
"@rpath/MyLib.dylib".

Xcode now has built-in support for building and packaging embedded dylibs. You 
may want to reconfigure your project to use it.


-- 
Greg Parker     gpar...@apple.com     Runtime Wrangler



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to