Fix (most) compilation issues on mac os x

Still it needs some work as the included libraries didn't work for me and I had to switch to homebrew provided ones, but at least the rest builds with this set of changes.

Hope you like it, please let me know if you need anything to merge this.

Regards,
Martin Häcker