Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 22nd, 2012  |  syntax: None  |  size: 0.64 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Shared Library Constructor is not executed
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. static void __attribute__ ((constructor)) test_init(void);
  6. static void __attribute__ ((destructor))  test_clean(void);
  7.  
  8. /*  Initialization  */
  9. static void     test_init(void){
  10.         fprintf(stderr,"initializedn");
  11.         fflush(stderr);
  12. }
  13. /*  CleanUp */
  14. static void test_clean(void){
  15.         fprintf(stderr,"cleaned upn");
  16.         fflush(stderr);
  17. }
  18.  
  19. double  test (double x){
  20.     return  2.0*x;
  21. }
  22.        
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. extern double   test(double x);
  26. void    main(void){
  27.  
  28.     printf("%.10en",test(10.0));
  29. }
  30.        
  31. gcc -shared -o testlib.so testlib.o