Compilation fixes.

Compilation was broken on 64-bit due to using a type-inferred index in a foreach (which always inferred as a size_t) in a calculation assigned to an int value.
The build script now links libdl on Posix systems.. a requirement with Derelict.