Created
December 16, 2010 08:08
-
-
Save deoxxa/743188 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
int load_plugin(char* location) | |
{ | |
void *lhandle = NULL; | |
void (*fhandle)() = NULL; | |
std::cout << "Loading plugin " << location << "\n"; | |
lhandle = dlopen(location, RTLD_LAZY); | |
if (lhandle == NULL) | |
{ | |
std::cout << "Could not load " << location << "\n"; | |
return 1; | |
} | |
fhandle = (void (*)()) dlsym(lhandle, "init"); | |
if (fhandle == NULL) | |
{ | |
std::cout << "Could not get function handle\n"; | |
return 2; | |
} | |
fhandle(); | |
dlclose(lhandle); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment