I'm on Windows/mingw64 and trying to generate webassembly with the Binaryen C API from a C application. I compiled the binaryen shared library libbinaryen.dll
without problems, and tried to reproduce the hello world example. It compiles and executes as expected, but it hangs on exit from main()
, both with a return
and with exit()
.
I thought there might be something wrong with exception handling since the Binaryen DLL is C++, but I see the same hang on main()
exit whether I compile and link with gcc
or g++
. Interestingly, if I compile the Binaryen as a static link library (libbinaryen.a
) and link that to my executable, the problem goes away, but this requires compiling with g++
. And it generates a 16Mb executable, so I'd rather not do that.
I'm using Mingw version x86_64-posix-seh-rev0, gcc 8.1.0, and linking with -lmingw32 -lbinaryen
. I have tried linking either directly to the DLL and to the link library, same result.
I'm guessing there is some problem with C/C++ interoperability here, but can't figure out what. The problem also causes gdb
to hang upon main()
exit, so I haven't been able to pinpoint exactly what happens.
Anyone seen this kind of behavior when calling C++ DLLs from C on mingw?