cxa_atexit with gcc3.2.3 on solaris2.6

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.
I am having a problem compiling gcc3.2.3 on solaris2.6.  I run configure this way:

mkdir gcc-objdir
cd gcc-objdir
../gcc-3.2.3/configure --prefix=/usr/local/gcc-3.2.3 --enable-shared --enable-threads=posix --enable-__cxa_atexit --with-as=/usr/ccs/bin/as  --with-ld=/usr/ccs/bin/ld --enable-languages=c++

The linker says that __cxa_atexit is not defined !!

If I do not use --enable-__cxa_atexit I could not do dlopen of a dynamic library with static objects. The samples are attached. These samples are not mine. To compile them I run:

g++ -shared libtest.so -fPIC test2.c
g++ -oprueba test.c

The output of 'prueba' is:
In main
In shared object
Shared object creating ...
Back in main
Goodbye, world.
Segmentation Fault(coredump)

What I could read in the Net is that the destructor of the static object inside g() is called after dlclose. Has anybody there know a solution for this?
Thanks.





      Seguí de cerca a la Selección Argentina de Rugby en el Mundial de Francia 2007.
http://ar.sports.yahoo.com/mundialderugby
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>

struct S {
  ~S () { printf ("Goodbye, world.\n"); }
};

typedef void (*fn_t)();

void f () { static S s; }

int main ()
{
  void *lib1;
  fn_t gp;

  printf ("In main\n");
  lib1 = dlopen ("./libtest.so", RTLD_LAZY);
  if ( lib1 == NULL ) {
      printf( "error dlopen: %s\n", dlerror() );
      return 1;
  }
  gp = (fn_t) dlsym (lib1, "g");
  if ( gp == NULL ) {
      printf( "error dlopen: %s\n", dlerror() );
      return 1;
  }
  (*gp) ();
  printf ("Back in main\n");
  f ();
  dlclose (lib1);
  exit (0);
}
#include <stdio.h>

struct T {
    T() {
        printf ("Shared object creating ...\n");
        fflush( stdout );
    }
    ~T () {
        printf ("Shared object going away...\n");
        fflush( stdout );
    }
};

extern "C" void g ()
{
    printf ("In shared object\n");
    static T t;
}

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux