Re: MSVC++ linking to MinGW compiled DLL
Thank you Earnie, JonY, and Greg!
I understand the name mangling issue... I was really hoping someone
would say "Oh yeah!... To get the MinGW GCC name mangling to be
compatible as MSVC++, add linker option
-Wl,--make_visual_c_compatible"... Or something. :P My impression is
that MinGW GCC can link to MSVC++ .DLL's (via pexports and/or reimp),
but MSVC++ cannot link to MinGW .DLLs... Does this seem accurate?
If so, I think that the MinGW FAQ item "How can an MSVC program call a
MinGW DLL, and vice versa?"
(http://www.mingw.org/mingwfaq.shtml#faq-msvcdll) should be updated to
reflect this. This item gives instructions on how to get MSVC to use
MinGW DLLs by creating a .DEF and then using MSVC's "lib.exe" tool...
Which doesn't actually work. At a minimum, it should mention that it
can work under the following conditions:
1. The calling convention must be __cdecl. (Lib.exe limitation)
2. Only C functions should be exported via 'extern "C"' because of
C++ name mangling issues.
Again, thank you for your suggestions and those links... Given that
there doesn't seem to be an "easy" (linker/tool) solution, using the
'extern "C"' method looks feasible and is likely what I'll do. I see
several additional benefits of employing that method as well.
Best Regards,
Dustin
-------------------------------------------------------------------------
(Continue reading)