Hello,
I am porting program to Windows. It consists of two parts: program and plugin.
Program dynamically loads plugin using dlopen+dlsym, or LoadLibrary+GetProcAddress.
Problem is that plugin needs to use a few symbols from program.
On Linux, I can do that:
$ cc -rdynamic program.c -o program
$ cc -fPIC plugin.c -o plugin.o
$ cc -shared plugin.o -o plugin.so
Everything works fine. But if I tried to compile it for Windows:
$ mingw-cc program.c -o program
$ mingw-cc plugin.c -o plugin.o
$ mingw-cc -shared plugin.o -o plugin.dll
I get 'undefined reference' error for all symbols from program.c. What can I do with it?
Andy, thank you, but..
I was used second way. I have something like that:
header.h:
typedef struct {
int (*first_function)(int x, float *z);
.
.
void (*last)(void *data);
} callbacks_t;
but using functions in this style:
plugin.c
int plugin_init( callbacks_t *f) {
f->last(&something)
}
wasn't ideal. First way like that: