npc.so #include int constructor() __attribute__((constructor)); int destructor() __attribute__((destructor)); void some_function(); int constructor() { printf("%s\n","Sup library"); } int destructor() { printf("%s\n","bye library"); } void some_function() { printf("%s\n","yo"); } GNU nano 1.3.6 File: main.cpp #include #include main.c int main() { void *lib_handle = dlopen("./npc.so",RTLD_LAZY); void (*funcd)()=NULL; if (lib_handle==NULL) { printf("%s\n","well shit"); } funcd=(void (*)())dlsym(lib_handle,"some_function"); if (funcd!=NULL) funcd(); dlclose(lib_handle); return 0; }