Allow building as DLL on Windows

Patch by jon_y on IRC.