Re: loading dynamic library at runtime
Re: loading dynamic library at runtime
- Subject: Re: loading dynamic library at runtime
- From: Greg Guerin <email@hidden>
- Date: Mon, 18 May 2009 15:24:50 -0700
Kurt Sutter wrote:
Those users want our app to link to their own library (which only
our users know the path to, we don't know that path when we build
our app).
So we would like to add a preference setting to our app, where the
user can specify (at his own risk) a non-standard path to the
library our app should link to.
Now, how could we do that?
I think a symlink would work. It can be embedded inside your app, so
need not affect any other app or installed lib.
You'd have to create a stub python library for linking your app,
whose install-name is the path of the symlink. You can just copy the
standard python lib file somewhere convenient for the project, then
change its install-name using 'install_name_tool'. You might have to
change the install-names of the libs it links to (i.e. the transitive
lib references).
Then in your app, create the symlink and make it refer to the
standard python lib path. Your app should run exactly the same as
always, because the symlink should be followed.
To change the app to use another python lib, simply replace the
normal symlink with one that points to the user's path.
You can also do symlinks to symlinks, up to 8, I think. More than
that and the symlink resolving code in the OS thinks it's in a loop
and barfs up an ELOOP in errno.
Note that following symlinks to libraries can have security
consequences. Every symlink that leads to trusted libs must be
trustworthy. If one isn't, apparently safe apps can have arbitrary
code injected into them.
-- GG
_______________________________________________
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