1. install cygwin on my PC. To avoid too much trying and failing, I have installed the full cygwin. Storage space is cheap but time is very expensive.
2. install mingw
3. download openssl from openssl.org. I used 0.9.8k
4. untar/unzip 0.9.8k package to cygwin how directory
5. start Cygwin xterm (ya, Cygwin not msys)
6. in the xterm, go to openssl-0.9.8k directory that you just unpacked
7. ./Configure mingw
8. make
The steps above create static library that can be used with mingw. To create the dll, you need to do:
$ echo EXPORTS > libcrypto.def
$ nm libcrypto.a | grep ' T _' | sed 's,^.* T _,,' >> libcrypto.def
$ dllwrap -o libcrypto.dll --def libcrypto.def libcrypto.a -lws2_32 -lgdi32
$ echo EXPORTS > libssl.def
$ nm libssl.a | grep 'T _' | sed 's,^.* T _,,' >> libssl.def
$ dllwrap -o libssl.dll --def libssl.def libssl.a libcrypto.dll
After this, you can copy the *.a to /mingw/lib and *.dll to /ming/bin