diff options
| author | qiuyiuestc <[email protected]> | 2010-11-21 23:12:42 +0000 |
|---|---|---|
| committer | qiuyiuestc <[email protected]> | 2010-11-21 23:12:42 +0000 |
| commit | 5f838f86aabed563975deb7cf01c04b96e1df0c8 (patch) | |
| tree | 69e887cf0f79b565cbc6dc1cb8993a3fe0e7c889 /components/module/extapp/extapp.c | |
| parent | 03951e4e38690ee0505c628156d9546142cb148c (diff) | |
add libdl and extension examples
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1080 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/module/extapp/extapp.c')
| -rw-r--r-- | components/module/extapp/extapp.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/components/module/extapp/extapp.c b/components/module/extapp/extapp.c new file mode 100644 index 0000000000..c638e9773c --- /dev/null +++ b/components/module/extapp/extapp.c @@ -0,0 +1,35 @@ +#include <rtthread.h> +#include <dlfcn.h> + +typedef void (*func)(void); + +int rt_application_entry(void) +{ + func f1, f2, f3, f4, f5; + + void* handle = dlopen("/mo/ext.so", RTLD_NOW); + if(handle != RT_NULL) + { + f1= (func)dlsym(handle, "function1"); + f2= (func)dlsym(handle, "function2"); + f3= (func)dlsym(handle, "function3"); + f4= (func)dlsym(handle, "function4"); + f5= (func)dlsym(handle, "function5"); + + if(f1 != RT_NULL) f1(); + else rt_kprintf("dlsym function1 failed.\n"); + if(f2 != RT_NULL) f2(); + else rt_kprintf("dlsym function2 failed.\n"); + if(f3 != RT_NULL) f3(); + else rt_kprintf("dlsym function3 failed.\n"); + if(f4 != RT_NULL) f4(); + else rt_kprintf("dlsym function4 failed.\n"); + if(f5 != RT_NULL) f5(); + else rt_kprintf("dlsym function5 failed.\n"); + } + + dlclose(handle); + + return 0; +} + |
