Assuming you are using Linux, you first need to add
#include <dlfcn.h>
Declare a function pointer variable in the appropriate context, e.g.
int (*alternative_server_init)(int, char **, char **);
As Ferruccio stated in https://stackoverflow.com/a/3/93514/ ... , explicitly load the library that you want to use by executing (select your favorite flags)
void* dlhandle; void* sym; dlhandle = dlopen("/home/jdoe/src/libwhatnot.so.10", RTLD_NOW|RTLD_LOCAL);
Read the address of the function you want to call later
sym = dlsym(dlhandle, "conflicting_server_init");
assign and produce as follows
alternative_server_init = (int (*)(int, char**, char**))sym;
Call like the original. Finally, unload by doing
dlclose(dlhandle);
vraa Jul 04 '13 at 14:12 2013-07-04 14:12
source share