public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc-2.91.2 AIX 4.3 shared library bug?
@ 1999-11-25 16:40 Markus Maier
  1999-11-30 23:28 ` Markus Maier
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Maier @ 1999-11-25 16:40 UTC (permalink / raw)
  To: help-gcc

Hi there,

I tried to build a shared C++ library with gcc-2.95.2 on AIX4.3
and load it with the dlopen function:
gcc was configured with option --shared.

// -- file main.c ---
#include <dlfct.h>
#include <stdio.h>
main() {
  void* h = dlopen("./mylib.so");
  if (!h) {
    puts(dlerror());
  else
    puts("ok");
}


// -- file mylib.cxx --
#include <iostream>

struct dummy {
  dummy() { cout << "global constructor\n"; }
};

dummy d;
// -- end of file


gcc -o main main.c
c++ -o myfile.o -c myfile.cxx

1. Using c++ -shared
  
  c++ -shared -o mylib.so myfile.o
  => linker warnings about duplicate symbols 
     _GLOBAL__DI, _GLOBAL__DD, ._GLOBAL__DI, ._GLOBAL__DD

  result of main program:
  => Exec format error

2. Using gcc -lstdc++-ar:
   gcc -shared -o mylib.so myfile.o -lstdc++-ar
   => no linker warnings
    
   result of main program:
  => Exec format error

3. Using the AIX system linker:

   ld -bhalt:4 -bM:SRE -bE:exports.exp -H512 -T512 -bnoentry -bbigtoc \
      -o mylib.so myfile.o -L<libstdc++-path> -lstdc++-ar -L<libgcc-path> \
      -lgcc -lc 

   result of main program:
   => ok

   Problem: no global constructors/destructors are called within
   mylib.so. However it seems that the global constructors of libstdc++ 
   are called (cout etc. works fine).

Is this a bug in gcc or am I doing something wrong?


-- Markus












^ permalink raw reply	[flat|nested] 2+ messages in thread

* gcc-2.91.2 AIX 4.3 shared library bug?
  1999-11-25 16:40 gcc-2.91.2 AIX 4.3 shared library bug? Markus Maier
@ 1999-11-30 23:28 ` Markus Maier
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Maier @ 1999-11-30 23:28 UTC (permalink / raw)
  To: help-gcc

Hi there,

I tried to build a shared C++ library with gcc-2.95.2 on AIX4.3
and load it with the dlopen function:
gcc was configured with option --shared.

// -- file main.c ---
#include <dlfct.h>
#include <stdio.h>
main() {
  void* h = dlopen("./mylib.so");
  if (!h) {
    puts(dlerror());
  else
    puts("ok");
}


// -- file mylib.cxx --
#include <iostream>

struct dummy {
  dummy() { cout << "global constructor\n"; }
};

dummy d;
// -- end of file


gcc -o main main.c
c++ -o myfile.o -c myfile.cxx

1. Using c++ -shared
  
  c++ -shared -o mylib.so myfile.o
  => linker warnings about duplicate symbols 
     _GLOBAL__DI, _GLOBAL__DD, ._GLOBAL__DI, ._GLOBAL__DD

  result of main program:
  => Exec format error

2. Using gcc -lstdc++-ar:
   gcc -shared -o mylib.so myfile.o -lstdc++-ar
   => no linker warnings
    
   result of main program:
  => Exec format error

3. Using the AIX system linker:

   ld -bhalt:4 -bM:SRE -bE:exports.exp -H512 -T512 -bnoentry -bbigtoc \
      -o mylib.so myfile.o -L<libstdc++-path> -lstdc++-ar -L<libgcc-path> \
      -lgcc -lc 

   result of main program:
   => ok

   Problem: no global constructors/destructors are called within
   mylib.so. However it seems that the global constructors of libstdc++ 
   are called (cout etc. works fine).

Is this a bug in gcc or am I doing something wrong?


-- Markus












^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-11-30 23:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-25 16:40 gcc-2.91.2 AIX 4.3 shared library bug? Markus Maier
1999-11-30 23:28 ` Markus Maier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).