Skip to content

Instantly share code, notes, and snippets.

@kjmkznr
Created October 24, 2014 03:10
Show Gist options
  • Save kjmkznr/927a2b7cc52eb6a1b74e to your computer and use it in GitHub Desktop.
Save kjmkznr/927a2b7cc52eb6a1b74e to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <dlfcn.h>
int main()
{
void *handle = dlopen("./libexample.so", RTLD_LAZY);
if (handle == 0) {
fprintf(stderr, "%s\n", dlerror());
return 1;
}
void (*helloworld)(void) = dlsym(handle, "helloworld");
if (helloworld == 0) {
fprintf(stderr, "%s\n", dlerror());
return 1;
}
helloworld();
if (dlclose(handle) != 0) {
fprintf(stderr, "%s\n", dlerror());
return 1;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment