ITEM: H9352L

MFCobol and C++ static constructors and destructors



Question:

        I have a RS/6000 590 running AIX 3.2.5. I am doing a test
program, a basic "hello world" output. I am doing a cout\<\< "hello
world";. I have no problem compiling and linking with the standard C++
or with C using a link to the library. When I try to do it through
Cobol I receive a segmentation fault. I have isolated the problem down
to the iostream.h. It fails at a constant character pointer to a
string.  This is my command line:
        cob -g -xv -L/usr/lpp/xlC/lib -lC -o d c.o bl.o

Response:

Customer COBOL code works, his c code
works, his C++ code works, and they work together until he tries to
include something in his C++ code that accesses iostream.h.  He has
called Micro Focus and was told that they do not support accessing C++
from COBOL.  However, he insists that he needs this facility and hopes
that someone can help him to get this working.  

This is not a COBOL problem rather a linker/loader problem.

Since the Cobol compiler is being used to perform the final link,
the C++ starup code is not being utilized.  XLC++ requires that the
C++ startup module /usr/lpp/xlC/lib/crt0.o is used.  If not, the
static constructors and destructors are not called on program startup
and exit, and therefore the C++ portions of the application will not
work; this is illustrated by the segmentation fault that Michael is
experiencing.  There is no way (currently) to combine MF Cobol and XL
C++ if the C++ code has static constructors and destructors.


Support Line: MFCobol and C++ static constructors and destructors ITEM: H9352L
Dated: June 1996 Category: N/A
This HTML file was generated 99/06/24~13:30:46
Comments or suggestions? Contact us