#include <dlfcn.h>
#include <stdio.h>

// C function pointer syntax is... something.
// Let's typedef our way out of this one.
typedef void (*greet_t)(const char *name);

int main(void) {
    // what do we want? symbols!
    // when do we want them? at an implementation-defined time!
    void *lib = dlopen("./main-greet", RTLD_LAZY);
    if (!lib) {
        fprintf(stderr, "failed to load library\n");
        return 1;
    }
    greet_t greet = (greet_t) dlsym(lib, "greet");
    if (!greet) {
        fprintf(stderr, "could not look up symbol 'greet'\n");
        return 1;
    }
    greet("venus");
    dlclose(lib);
    return 0;
}
