Article View: gnu.gcc.bug
Article #5975Static initialization in a dynamically loaded library
From: Biplav Srivastava
Date: Fri, 17 Jan 1997 00:00
Date: Fri, 17 Jan 1997 00:00
61 lines
1947 bytes
1947 bytes
Hi,
I have a C program which dynamically loads a shared library (.so) on
SunOS. The shared library is developed in C++ and has a C wrapper.
There are "cout" calls in the library. Please see the illustration
below.
The .so is loaded and the wrapper gets correctly called. But
when the control comes to the first "cout" statement of the C++ code, I
get a core dump. I can neither change my C program with the main()
routine nor replace it with a C++ program with main().
How have others handled the problem ? Any ideas ? My guess is that
static initialization of the C++ library is not happening. How
to force it ?
BTW, I have tried this with both GNU and Centerline compilers.
Regards,
Biplav
PS:
To illustrate the scenario,
Program in C: C_prog_with_main.c()
------------------
main() {
...
call_c_wrapper();
...
}
Wrapper in C : C_wrapper.c
-----------
extern "C" {
call_c_wrapper() {
cplus_class::do_something();
}
};
C++ code: cplus_part.c
------------
#include <iostream.h>
...
cplus_class::do_something() {
cout << " I cause all the trouble " << endl;
}
.....
-----------------------------------------------------------
Technical Details
Message-ID:
<Pine.SUN.3.91.970117153129.9502L-100000@redrock>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 113d02,cd4ef7d1c94d6a7e,start X-Google-Attributes: gid113d02,public From: biplav.srivastava@tempe.vlsi.com (Biplav Srivastava) Subject: Static initialization in a dynamically loaded library Date: 1997/01/17 Message-ID: <Pine.SUN.3.91.970117153129.9502L-100000@redrock> X-Deja-AN: 210546110 sender: bug-gcc-request@prep.ai.mit.edu x-sender: bsrivast@redrock content-type: TEXT/PLAIN; charset=US-ASCII x-gateway: relay5.UU.NET from bug-gcc to gnu.gcc.bug; Fri, 17 Jan 1997 17:37:56 EST mime-version: 1.0 newsgroups: gnu.gcc.bug