Friday, November 23, 2012

Building OpenSSL applications

An user has reported problems building an application that use OpenSSL libraries supplied with my MinGW Distro. While he didn't provide further details I think his problem was related to some missing library dependencies.
Any application using OpenSSL has to link with (in this order): ssl, crypto, ws2_32 and gdi32. ssl and crypto are the OpenSSL libraries themselves. ws2_32 is the import library for the Winsock DLL WS2_32.DLL and gdi32 is the import library for GDI32.DLL. The latter is needed because, on Microsoft Windows, OpenSSL uses windows events (eg, mouse movements) as an entropy source.
If you are using a IDE (like Codelite or Code::Blocks) make sure to add those libraries to the project settings.