post
poster: toraton
description: main.c - dlsym example
language: C
[download]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <dlfcn.h>

int main(void) {
    void *handle;
    int (*add)(int, int);

    handle = dlopen("./libadd.so", RTLD_LAZY);
    printf("%s\n", dlerror());

    add = (int (*)(int, int)) dlsym(handle, "add");
    printf("%s\n", dlerror());

    add(1, 2);
    return 0;
}