Back to index

glibc  2.9
tststatic.c
Go to the documentation of this file.
00001 #include <dlfcn.h>
00002 #include <stdio.h>
00003 #include <stdlib.h>
00004 
00005 int
00006 main (void)
00007 {
00008   void *handle;
00009   int (*test) (int);
00010   int res;
00011 
00012   handle = dlopen ("modstatic.so", RTLD_LAZY);
00013   if (handle == NULL)
00014     {
00015       printf ("%s\n", dlerror ());
00016       exit(1);
00017     }
00018 
00019   test = dlsym (handle, "test");
00020   if (test == NULL)
00021     {
00022       printf ("%s\n", dlerror ());
00023       exit(1);
00024     }
00025 
00026   res = test (2);
00027   if (res != 4)
00028     {
00029       printf ("Got %i, expected 4\n", res);
00030       exit (1);
00031     }
00032 
00033   dlclose (handle);
00034   return 0;
00035 }