Works.
Although I had to remove EXPORT_VAR_AS_FN.
[color=blue]
> 2. Modify Makefile shared so it would call
> util/mkdef.pl script. and add generated .def file to linking
> command Note that DEF file should contain correct DLL name, not
> just crypteay32 mingw32 builds libcrypto-0.9.8.dll, and this name
> should exactly appear in the .def file[/color]

I couldn't understand what I should do...
First of all the asn1 stuff does not compile... Strange. I use
openssl-0.9.8d and mingw32-gcc (GCC) 4.1.1.
The problem lays in ASN1_ITEM_ref, which returns none constant item
into constants arrays declares by ASN1_SIMPLE.

But assuming I remove this code, which target do you copy? cygwin?
You just add $(LIBNAME).def to SHAREDFLAGS?
[color=blue]
> 3. Forget about dllwrap and such. Modern Mingw32 produce absolutely
> correct dlls with just gcc -shared -o dllname,
> if you specify .def file along with object file.[/color]