I have some global variable defined in global.c file as below:
int globalvar;
I have a header file global.h that declares this variable as extern
extern int globalVar;
Now I have main.c that gets linked with compiled global.o (compiled from global.c) having code to open (using dlopen) a shared object sh.so that gets built from sh.c with access to globalVar, through global.h. Although, my executable has definition of globalVar (statically linked), when I load the dynamically linked library sh.so, it says undefined globalVar. How to handle this?