#include #include #include typedef void (*init_ptr)(); int main( int argc, char *argv[] ) { void* lib_handle; /* handle of the opened library */ lib_handle = dlopen("master.so", RTLD_NOW); if (!lib_handle) { fprintf(stderr, "Error during dlopen(): %s\n", dlerror()); exit(1); } else { init_ptr func_init; char *error_msg; puts("Master loaded, finding load_slave() symbol"); func_init = (init_ptr) dlsym( lib_handle, "load_slave" ); error_msg = dlerror(); if( error_msg ) fprintf( stderr, "Can't find load_slave\n"); else { printf( "load_slave found at %p, executing it\n", func_init); (*func_init)(); } } dlclose( lib_handle ); }