Fix dynamic linking problem on OS X