$ echo | gcc -E -dM -
Start with following article: Stdcall and DLL tools of MSVC and MinGW. You can read there that in MSVC DLL functions in stdcall calling convention and marked as __declspec(dllexport) are decorated with leading underscore and closing @nn, where nn is the number of bytes in the argument list. However, in MinGW DLL you won't find the underscore and this is a problem for MSVC applications loading DLLs and expecting such functions. The solution is to add aliases to .def's EXPORTS section with leading underscores. Makefile entry with sed doing the trick:
$(DLL): $(OBJS) dlltool -z $(@:.dll=.def) $(OBJS) del $(@:.dll=.def).bak 2>nul sed -ri.bak "/^EXPORTS/,/^[^ \t]/s/^([ \t]+)([^ \t]+).*/\1\2\n\1_\2 = \2/" $(@:.dll=.def) $(CXX) -shared -o $@ $(@:.dll=.def) $(OBJS)