loading dynamic library at runtime
loading dynamic library at runtime
- Subject: loading dynamic library at runtime
- From: Kurt Sutter <email@hidden>
- Date: Mon, 18 May 2009 21:10:43 +0200
I am not sure if this is the right place to post the following
question, but I found none better.
I have an app that links to a dynamic library (namely Python). Python
exports a lot of symbols, and we are using many of them.
Usually, the library is in a well-defined place, namely the Python
framework (whose C API we are calling), and using it from within our
app is trivial. The library (or, rather, its framework
Python.framework) is part of our project. The dynamic linker does all
the work for locating the library, tying our app's external links to
it, etc.
Now, we have users who have their own specific version of that library
installed somewhere (because the Python framework on MacOS always lags
behind the currently available versions). 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? The obvious road would be _not_ to include
the library (i.e. the python framework) in our project, and, at
runtime to use dlopen() and then dlsym() to open the library and to
import the symbols we need. However, this seems very inelegant, in
particular because it would force us to not only import each symbol
that we need, but also to declare the type of each imported symbol.
Therefore, is there a more elegant way to do this? Can our app tell
the loader to automatically link our app to some other library than
the one under /System/Library/Python.framework?
Any advice would be appreciated.
Regards
Kurt Sutter
_______________________________________________
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