Back to index

glibc  2.9
initfirst.c
Go to the documentation of this file.
00001 #include <dlfcn.h>
00002 #include <stdio.h>
00003 
00004 int
00005 main (void)
00006 {
00007   void *h = dlopen ("firstobj.so", RTLD_LAZY);
00008   void *f;
00009   if (! h)
00010     {
00011       printf ("cannot find firstobj.so: %s\n", dlerror ());
00012       return 1;
00013     }
00014   f = dlsym (h, "foo");
00015   if (! f)
00016     {
00017       printf ("cannot find symbol foo: %s\n", dlerror ());
00018       return 2;
00019     }
00020   ((void (*) (void)) f) ();
00021   return 0;
00022 }