Support building in MacOSX

- This commit adds the first two patches from issue#13
- Support gui=qt for MacOSX
- undef some MacOSX specific symbols