  We give formulae for the Ozsvath-Szabo invariants of 4-manifolds X obtained
by fiber sum of two manifolds M_1, M_2 along surfaces S_1, S_2 having trivial
normal bundle and genus g>0. The formulae follow from a general theorem on the
Ozsvath-Szabo invariants of the result of gluing two 4-manifolds along a common
boundary, which is phrased in terms of relative invariants of the pieces. These
relative invariants take values in a version of Heegaard Floer homology with
coefficients in modules over certain Novikov rings; the fiber sum formula
follows from the theorem that this "perturbed" version of Heegaard Floer theory
recovers the usual Ozsvath-Szabo invariants, when the 4-manifold in question
has b^+>1. The construction allows an extension of the definition of the
Ozsvath-Szabo invariants to 4-manifolds having b^+ = 1 depending on certain
choices, in close analogy with Seiberg-Witten theory. The product formulae lead
quickly to calculations of the Ozsvath-Szabo invariants of various 4-manifolds;
in all cases the results are in accord with the conjectured equivalence between
the Ozsvath-Szabo and Seiberg-Witten invariants.
