Fix mac linking as well by moving the flags before the output argument