OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [linux/] [uClibc/] [test/] [dlopen/] [test2.c] - Blame information for rev 1765

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
#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
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.