Fix compile and link error for OSX