-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello.c
38 lines (28 loc) · 941 Bytes
/
hello.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include <dlfcn.h>
#include "hello_static_implicit.h"
#include "hello_static_explicit.h"
#include "hello_dynamic_partial.h"
void say_hello_direct()
{
printf("say hello direct\n");
}
int main(int argc, char const *argv[])
{
printf("----------------------------------\n");
say_hello_direct();
printf("----------------------------------\n");
say_hello_static_implicit();
printf("----------------------------------\n");
say_hello_static_explicit();
printf("----------------------------------\n");
say_hello_dynamic_partial();
printf("----------------------------------\n");
void *handle = dlopen("./libhello_dynamic_full.so", RTLD_LAZY);
void (*say_hello_dynamic_full)(void);
say_hello_dynamic_full = (void (*)(void))dlsym(handle, "say_hello_dynamic_full");
say_hello_dynamic_full();
dlclose(handle);
printf("----------------------------------\n");
return 0;
}