Monthly Archives: April 2009

Building OpenSSL via MinGW

OpenSSL is a particularly difficult one to build on MinGW, and it’s not clear even what approach will work. But I got it to build.

My MinGW/MSYS configuration is with the full suite of tools, including bash. (Follow these FFmpeg build instructions for setup.)

As well, I’m using GCC 4.3.3, from the TDM recent builds (http://www.tdragon.net/recentgcc/) setup.

I’m building OpenSSL 0.9.8k.

You need ActivePerl. MinGW has a /bin/perl, but it’s not up to the task. See OpenSSL’s INSTALL.WIN32 file for details.

From a Win32 command prompt (not bash), set up the your paths:

  • First in the path: ActivePerl’s bin directory.
  • Then MinGW’s paths (before Win32 native).

Fix the file e_os2.h, per BUG 1685. Remove the “static” modifier in the OPENSSL_IMPLEMENT_GLOBAL macro. (Note that it’s a 3-line macro.) This gets you by the “crypto/des/set_key.c line 72” compile error.

Run msmingw32.bat. It will fail with “/bin/sh: copy: command not found”.

Now, edit the file msmingw32a.mak. This gets generated by every run of the msmingw32.bat file. Search for “exist” and you’ll see two DOSish commands:

if exist $(O_CRYPTO) ] $(RM) $(O_CRYPTO)

Change each to its bash equivalent:

if [ -e $(O_CRYPTO) ]; then $(RM) $(O_CRYPTO); fi

Finally, run the make, and specify the MinGW copy command:

make -f ms/mingw32a.mak “CP=cp”

The output files are in the ‘out’ subdirectory. Intermediate files are in ‘tmp’.

Include files are in ‘outinc’: the include/openssl directory has zero-byte place-holders for each file.

Make’s “clean” and “test” targets are broken. To clean, remove tmp and out. To test, run the various test programs in the ‘out’ directory.

All tests pass.

If you get missing symbols like DeleteDC and send when linking against libcrypto, you’ll need to include some win32 libraries. This typically does it:

make LIBS=”-lgdi32 -lws2_32″