I studied and tested the following URLS closely, Calling function in shared library (Linux) get Segmentation Fault as well as https://git.xeserv.us/Quora/dlsym-example/src/master/testprog.c. My question is how to map dlsym to a non-static C++ member function similar to this C function example. If I substitute C function syntax for a non-static C++ member function , I get a no-op.
void *lib; /* void pointer named lib */
void (*sayHello)(void); /* void pointer named sayHello */
lib = dlopen("helloWorld.so", RTLD_NOW);
*(void **) (&sayHello) = dlsym(lib,"_ZN19CDataTransferServer10InitializeEi13CC_SAMPLETYPEjjj");
Any help is appreciated.
Consider loading a method by its mangled name extracted with
readelf -Ws libmy.so
or
nm -g libmy.o