Generalized inverses over integral domains