We use the construction of unfolded Seiberg–Witten Floer spectra of general 3-manifolds defined in our previous paper to extend the notion of relative Bauer–Furuta invariants to general 4-manifolds with boundary. One of the main purposes of this paper is to give a detailed proof of the gluing theorem for the relative invariants.