This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: How to create objects of a class defined in .so file?


On Dec  4, 2000, "Rajesh Lolam" <rajeshlolam@rediffmail.com> wrote:

> 1> How to create an object of class (SharedClass)?

Create an extern "C" function that returns pointers to such objects,
and use dlsym() to obtain a pointer to that function.

> 2> How to use methods of class (SharedClass?)

For this to work, you'll either have to wrap all class methods with
extern "C" functions, and use dlsym to get their addresses, or link
the library explicitly into your application, instead of dlopen()ing
it, so that your code can refer explicitly to the methods.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]