void bar(void);
#include <stdio.h>#include <dlfcn.h>#include "mud.h"typedef void (*foo_t)();int main() { void* foo_lib = dlopen("./foo.so", RTLD_LAZY); foo_t foo = (foo_t) dlsym(foo_lib, "foo"); bar(); foo();}void bar(void) { printf("bar\n");}
#include <stdio.h>#include "mud.h"int foo() { printf("foo\n"); bar();}
all: mud.exe foo.so mud.exe: mud.o gcc -Wl,–export-all-symbols -Wl,–out-implib=libmud.a -o $@ $^ foo.so: foo.o gcc -shared -o $@ $^ -L./ -lmud.c.o: gcc -c $*.c -o $*.o
mud.h
mud.c
foo.c
makefile
Aside: Always post warning and error messages when you request help.