Home | History | Annotate | Download | only in input
      1 #include <dlfcn.h>
      2 #include <stdio.h>
      3 
      4 int main(int argc, char **argv) {
      5   if (argc < 2) {
      6     puts("usage: main.out libtest.so");
      7     return 1;
      8   }
      9 
     10   void *handle = dlopen(argv[1], RTLD_NOW);
     11   if (!handle) {
     12     puts("failed to open lib");
     13     return 1;
     14   }
     15 
     16   void (*test)(void) = dlsym(handle, "test");
     17   if (!test) {
     18     puts("failed to find test() function");
     19   } else {
     20     test();
     21   }
     22 
     23   dlclose(handle);
     24   return 0;
     25 }
     26