OSDN Git Service

test/math: don't try to build test dep as test
[uclinux-h8/uclibc-ng.git] / test / dlopen / test2.c
1 #include <fcntl.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <dlfcn.h>
5
6 #ifdef __UCLIBC__
7 extern void _dlinfo(void);
8 #endif
9
10 int main(int argc, char **argv) {
11         void *handle;
12         int (*mydltest)(const char *s);
13         char *error;
14
15         handle = dlopen ("./libtest2.so", RTLD_LAZY);
16         if (!handle) {
17                 fprintf(stderr, "Could not open ./libtest2.so: %s\n", dlerror());
18                 exit(1);
19         }
20
21         handle = dlopen ("./libtest1.so", RTLD_LAZY);
22         if (!handle) {
23                 fprintf(stderr, "Could not open ./libtest1.so: %s\n", dlerror());
24                 exit(1);
25         }
26
27         mydltest = dlsym(handle, "dltest");
28         if ((error = dlerror()) != NULL)  {
29                 fprintf(stderr, "Could not locate symbol 'dltest': %s\n", error);
30                 exit(1);
31         }
32
33         mydltest("hello world!");
34
35         dlclose(handle);
36
37         return EXIT_SUCCESS;
38 }
39