From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Markus Maier" To: Subject: gcc-2.91.2 AIX 4.3 shared library bug? Date: Thu, 25 Nov 1999 16:40:00 -0000 Message-id: <000201bf37a7$5fe62e50$a8d50d81@mach.unikarlsruhe.de> X-SW-Source: 1999-11/msg00394.html 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 #include main() { void* h = dlopen("./mylib.so"); if (!h) { puts(dlerror()); else puts("ok"); } // -- file mylib.cxx -- #include 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 -lstdc++-ar -L \ -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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Markus Maier" To: Subject: gcc-2.91.2 AIX 4.3 shared library bug? Date: Tue, 30 Nov 1999 23:28:00 -0000 Message-ID: <000201bf37a7$5fe62e50$a8d50d81@mach.unikarlsruhe.de> X-SW-Source: 1999-11n/msg00394.html Message-ID: <19991130232800.sCfCT96XzbEE1SiUsfl769iqys0TkLefVJVo9IOoWX0@z> 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 #include main() { void* h = dlopen("./mylib.so"); if (!h) { puts(dlerror()); else puts("ok"); } // -- file mylib.cxx -- #include 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 -lstdc++-ar -L \ -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