Re: Uber-Dynamic Linkery
Re: Uber-Dynamic Linkery
- Subject: Re: Uber-Dynamic Linkery
- From: Mark Wagner <email@hidden>
- Date: Wed, 05 Jun 2013 15:53:16 -0700
On Fri, May 31, 2013 at 10:42 PM, Jerry Krinock
<email@hidden> wrote:
On 2013 May 31, at 06:10, Jonas Maebe <
email@hidden> wrote:
> Look up the address of the function at run time (e.g. using dlopen/dlsym).
Thank you, Jonas!
I started using dlopen() and dlsym() per the Apple documentation [1], which discusses how to load plain C functions at runtime. Not too bad. But then I ran into a member function from a C++ class. Oh, no! I found this very good article [2] on how to dynamically load C++, but it looks as though the Mozilla declarations are not extern "C", so it's not going to work. And to make matters worse, a template seems to be involved. I hate C++.
If anyone has any other ideas, let us know. Should I try harder with the C++? I'm even considering whether I should download the Mozilla source code (Oh no!!!) and try to build my own little static library which defines the handful of functions and classes that I need.
You can use dlopen()/dlsym() to load C++ symbols, but it's harder. You'll need to figure out the mangled names for the functions to pass to dlsym(), and you may need to play around with calling conventions to get things working.
I'd just create a pair of "shim" libraries that simply wrap 'extern "C"' around the functions you need, one for old Firefox and one for new, and use dlopen()/dlsym() to load the shim you want at runtime.
--
Mark Wagner
_______________________________________________
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