This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

istream error, C calling C++ DLL


I am stuck on a problem with my C++ program which occurs when it is built
with -static, but the problem goes away if I allow it to link dynamically.

My C++ program is a DLL.

The error only occurs if my DLL is linked in from a C program. It doesn't
occur if my DLL is linked in from a C++ program.

The error only occurs on one particular function in the DLL - other
functions work fine, even when called from the C program.

Here are my linker options for building dynamic:
g++ -o proparse.dll $(OBJS) -shared -Wl,--export-dynamic

Here are my linker options for building static:
g++ -o proparse.dll $(OBJS) -shared -Wl,-static -Wl,--export-dynamic

Here is the relevant output from gdb and the core file:

#0  __strtol_internal (nptr=0xbffff854 "\210$­û", endptr=0x405b4c00,
base=1075274236, group=1074405810) at eval.c:36
36      eval.c: No such file or directory.
        in eval.c
(gdb) bt
#0  __strtol_internal (nptr=0xbffff854 "\210$­û", endptr=0x405b4c00,
base=1075274236, group=1074405810) at eval.c:36
#1  0x400a2213 in _IO_getc (fp=0xbffff854) at getc.c:41
#2  0x40504cb2 in istream::get () from /usr/lib/proparse.dll

With debug messages, I've verified that the problem does occur right where
istream::get is called. The same sort of error occurs with tellg, seekg, and
peek. However, the istream itself appears to be OK:
	good 1 eof 0 fail 0 bad 0

I'm running Red Hat 7.1, and have this same problem with 2.96.85 as well as
2.96.99. I'm aware of an exceptions related bug with C++ DLLs being linked
by C programs with 2.96.81, but that was fixed with 2.96.85 (I witnessed the
results of that bug as well).

I get the same error on Mandrake 7.1 with 2.95.3: I get a Segmentation
fault, but no core file. I confirmed that the error was coming from the same
spot with debug messages.

This problem doesn't seem to exist with Mingw 2.95.2 on Windows, but I use
dllwrap for that.

I will try to reproduce the problem with a small test case, but I'm hoping
that somebody will recognize the problem from this description and give me
some advise.

Thanks in advance,
John


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]