Created
October 24, 2014 03:10
-
-
Save kjmkznr/927a2b7cc52eb6a1b74e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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