/* Open a shared library. */ handle = dlopen( "/usr/nto/x86/lib/libfoo.so.1", RTLD_NOW );
/* Find the address of a function and a global integer. */ brain = (foofunc)dlsym( handle, "takeover_world" ); some_global_int = (int* )dlsym( handle, "my_global_int" );
/* Invoke the function and print the int. */ x = (*brain)( 5 ); printf( "that global is %d\n", *some_global_int );Check to see if a function is defined, and call it if it is: