- //testso1.c
- #include <stdio.h>
- int so1func1()
- {
- printf("so1func1\n");
- return 0;
- }
- int so1func2()
- {
- printf("so1func2\n");
- return 0;
- }
- //testso2.c
- #include <stdio.h>
- int so1func1();
- int so2func1()
- {
- printf("so2func1_ call so1func1\n");
- so1func1();
- return 0;
- }
- //main.c
- #include <stdio.h>
- #include <stdlib.h>
- #include <dlfcn.h>
- // int so1func1();
- // int so2func2();
- int main(int argc, char *argv[])
- {
- typedef int (*UI_MAIN)();
- void *handle = NULL;
- printf("test_main\n");
- // load core
- handle = dlopen("./libtestso1.so", RTLD_GLOBAL|RTLD_LAZY);
- //handle = dlopen("./libtestso1.so", RTLD_LAZY);
- if(!handle){
- printf("read ui_core error: %s \n", dlerror());
- return 1;
- }
- UI_MAIN ui_main = (UI_MAIN) dlsym(handle, "so1func1");
- if (ui_main)
- ui_main();
- handle = dlopen("./libtestso2.so", RTLD_LAZY);
- if(!handle){
- printf("read ui_main error: %s \n", dlerror());
- return 1;
- }
- ui_main = (UI_MAIN) dlsym(handle, "so2func1");
- if (ui_main)
- ui_main();
- else{
- printf("read symbol error: %s \n", dlerror());
- return 1;
- }
- //so1func1();
- //so2func2();
- return 0;
- }