///////////////////////////////////////////////////////////////////////////// // Rev 11/12/2003 // // // HELLODYN.CPP // ------------ // // // Sylvain MARECHAL - sylvain.marechal1@libertysurf.fr ///////////////////////////////////////////////////////////////////////////// // // DLL and unix - Dynamic link // ///////////////////////////////////////////////////////////////////////////// #include #include typedef void (*PFHelloShared)(int ); int main(void) { const char *error; void *module; PFHelloShared pfHelloShared; /* Load dynamically loaded library */ module = dlopen("./libshared.so", RTLD_LAZY); if (!module) { fprintf(stderr, "Couldn't open the .so: %s\n", dlerror()); exit(1); } /* Get symbol */ dlerror(); pfHelloShared = (PFHelloShared)dlsym(module, "HelloShared"); if ((error = dlerror())) { fprintf(stderr, "Couldn't find hello: %s\n", error); exit(1); } /* Now call the function in the DL library */ (*pfHelloShared)(8888); /* All done, close things cleanly */ dlclose(module); return 0; }