Implement dynamic linking on Windows

There need to be some way to get the calling conventions right to make
it really useful. But this will at least unbreak the build for Windows
and it works correctly for normal C calls.

Tested on Windows and Linux.