dlopen_test.c

corecode, 07/16/2006 12:58 PM

Download (560 Bytes)

 
1
#include <dlfcn.h>
2
#include <stdio.h>
3
#include <stdlib.h>
4

    
5
int main(void) {
6
   void* handle;
7
   void* func;
8

    
9
   handle = dlopen("libssl.so",  RTLD_NOW | RTLD_GLOBAL);
10
   if (handle) {
11
      func = dlsym(handle, "CRYPTO_set_id_callback");
12
      if (!func) {
13
         printf("error, can't load CRYPTO_set_id_callback\n");
14
         exit(1);
15
      } else {
16
         printf("loaded CRYPTO_set_id_callback\n");
17
         exit(0);
18
      }
19
   } else {
20
      printf("error, can't open libssl.so: %s\n", dlerror());
21
      exit(1);
22
   }
23
   dlclose(handle); 
24
   exit(0);
25
}