Cheers,
Brian.
(short example attached)
:::::::: wibble.c
#include <stdio.h>
void entry(void)
{
printf("Hello, world!\n");
}
:::::::: main.c
#include <dlfcn.h>
#include <stdio.h>
int main(void)
{
const char *e;
void (*p)();
void *h = dlopen("./wibble.o", RTLD_NOW);
if (!h) {
printf("Failed: %s\n", dlerror());
return 1;
}
p = dlsym(h, "entry");
e = dlerror();
if (e) {
printf("Failed(2): %s\n", e);
return 1;
}
p();
dlclose(h);
return 0;
}
Compile like this:
gcc -Wall main.c -o main -ldl
gcc -Wall -shared wibble.c -o wibble.o
./main