This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
gcc-2.91.2 AIX 4.3 shared library bug?
- To: <help-gcc at gnu dot org>
- Subject: gcc-2.91.2 AIX 4.3 shared library bug?
- From: "Markus Maier" <maier at pdtec dot de>
- Date: Fri, 26 Nov 1999 01:44:19 +0100
- Reply-To: <maier at pdtec dot de>
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