Well, i have had a play and i think using dlopen and dlsym is the best way to go about this. Here's some examples if anyone is interested:
libtest.c
Code:
#include <stdio.h>
void testfunc() {
printf("Test plugin\n");
}
Compiled as follows:
gcc -fPIC -g -c -Wall libtest.c
main.c
Code:
#include <stdio.h>
#include <dlfcn.h>
int main () {
void *handle = NULL;
void (*testlib)(void) = NULL;
handle = dlopen("./libtest.so" ,RTLD_LAZY);
testlib = dlsym(handle, "testfunc");
if ( testlib == NULL )
{
printf("Error: %s \n", dlerror());
}
else
{
testlib();
}
}
compiled with: gcc main.c
making the library into a shared library ( required )
Code:
gcc -shared -Wl,-soname,libtest.so.1 -o libtest.so libtest.o -lc
__________________
"No, that's wrong, Cartman. But don't worry, there are no stupid answers, just stupid people." -- Mr. Garrison
Forum Netiquette