Open kvnnap opened 5 years ago
@kvnnap any Updates here? Facing the same issue with i686-w64-mingw32 (even with sjlj enabled).
64 bit works fine
@nbfacilioo This was a while ago. In my case, I ended up avoiding static compilation and linking everything dynamically. I think that the standard library is compiled differently between dynamic and static, example different flags may be used. I suspect that potential structures differ between these two versions and end up being incompatible. This is all speculation based on intuition as I don't have time to get into it right now. Sorry I can't offer better help
This problem is very similar to this issue on stack overflow. In fact I am the author of that question, however I never truly understood what I did wrong.
I created a Windows DLL using the following code:
Header (dllexport.h):
Implementation (main.cpp):
Client (clientOOP.cpp)
Compilation steps:
DLL
Client
When I run clientOOP.exe, get the following output and exits:
When debugging this, gdb reports it returned exit code 3. If I comment
throw 2;
it works as expected.The problem does not occur if I also statically link libstdc++ and libgcc into the clientOOP executable, or if I do not statically link these libraries in the DLL at all.
I would like to understand why this happens. I know that one should not be throwing exceptions over DLL boundaries and I am not doing so. I am merely exposing a C interface, and everything C++-like is handled internally inside the DLL. As such, the call stack should be Dwarf2 aware in there. This scenario never happens on 64-bit MinGW or on Ubuntu 64/32 bit.
I did investigate trying to use this DLL within a pure-c program, and to my surprise it works! Here's the code I used: (client.c)
compiled using:
and this outputs:
Please help me understand what is happening.