/* compiled with cc -Wall -pedantic -ansi -rpath . -L. -o perl_test2 perl_test2.c */ #include #include #include int main(void) { void *mod = NULL; void (*func)(void); if((mod = dlopen("perl_test1.so", (RTLD_LAZY | RTLD_LOCAL))) == NULL) { fprintf(stderr, "Failed loading module: %s\n", dlerror()); exit(-1); } if((func = (void *)dlsym(mod, "pprint")) == NULL) { fprintf(stderr, "Failed locating symbol: %s\n", dlerror()); dlclose(mod); } else { (*func)(); } exit(0); }