Re: Simple question on locating dynamic libraries at runtime
Re: Simple question on locating dynamic libraries at runtime
- Subject: Re: Simple question on locating dynamic libraries at runtime
- From: Chris Goedde <email@hidden>
- Date: Thu, 5 Aug 2010 08:09:00 -0500
On Aug 4, 2010, at 2:25 PM, I wrote:
> Hi all,
>
> I'm adapting an existing Cocoa project to interface with Matlab, which requires linking to a dynamic library supplied by The Mathworks. I have it all set up so that compiling and linking works, but I can't figure out how to tell Xcode how to tell my app where to look for the dynamic library at run time. The library itself [libeng.dylib] lives in /Applications/MATLAB_R2009a.app/bin/maci, and I've created a sym link to this folder at /usr/local/matlab/bin.
>
> The story so far: ...
Thanks to everyone who replied. That was very helpful. I didn't realize that @loader_path was baked into the dynamic library; I assumed it was added as a default by Xcode.
This app is meant to be used primarily by me (or perhaps students working for me), on my own machine(s). After thinking about the pros and cons of various solutions, I decided to have Xcode copy the dynamic library into my app's bundle. The snag with that is that libeng.dylib is only the tip of the iceberg; it depends on some as yet unknown number of libraries (at least 9, but there are 155 *.dylib files in that folder ...).
My current solution is to just use ~/.MacOS/environment.plist to set DYLD_LIBRARY_PATH to /usr/local/matlab/bin. But if I want to pursue a solution in Xcode, I have a couple questions.
(1) What's the best way to suss out all the dependencies between the dynamics libraries? I was using otool -L, but libA -> libB -> libC, etc, so it's tedious. Is there a better way?
(2) Once I identify all the required libraries, what's the best, most future-proof, most maintainable way to copy them into my app's bundle? (Note that some of the dependencies are actually sym links, e.g. libeng.dylib is linked to libicudata.dylib.38, which is actually a sym link to the file libicudata.dylib.38.1.)
(3) Something else? (I'm hesitant to play around with install_name_tool because of the maze of dependencies in the libraries.)
Thanks.
Chris Goedde
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden