1. Moved to correct forum.
> but it's still a kind of cross posting
2. It's the more acceptable kind, since Osiris990 has actually waited for several days without reply before trying the next forum on the list. It's the ones who broadcast in several places at the same time which are the real bane.
3. A 1-function main() calling a 1-function DLL, and showing how you linked the various components.
Code:
$ cat bar.c
#include <stdio.h>
#include <dlfcn.h>
void myfunc ( void (*fn)(void) ) {
printf("In dl func, calling back\n" );
fn();
printf("In dl func, done\n" );
}
$ cat foo.c
#include <stdio.h>
#include <dlfcn.h>
void callback ( void ) {
printf("In callback\n");
}
int main() {
void *lib = dlopen("bar.so",RTLD_NOW);
if ( lib ) {
void *f1 = dlsym(lib,"myfunc");
void (*func)(void (*)(void)) = (void(*)(void (*)(void)))f1;
func(callback);
dlclose(lib);
} else {
printf("%s\n",dlerror() );
}
return 0;
}
$ gcc -o bar.so bar.c -shared
$ gcc foo.c
$ ./a.exe
In dl func, calling back
In callback
In dl func, done
Experiment with simple ideas, then try to integrate them into your main application.
Also, experiment with the major ideas you're likely to need in the whole project before trying to actually use them.