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

Alexandre Oliva aoliva@redhat.com
Tue Dec 5 09:00:00 GMT 2000


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


More information about the Gcc-help mailing list