More robust method for locating libdir