Let $\Omega \subset \mathbb R^n$ be open and bounded. Given the Poissons equation with Neumann-boundary, e.g.
$$-\Delta u = f \quad \text{and}\quad \frac{\partial u}{\partial n}=g, $$ we must require the compatibility condition $$\int_\Omega f \, \mathrm dx + \int_{\partial \Omega} g \, \mathrm dS=0$$ which follows from the divergence theorem:
$$\int_{\Omega} f \, \mathrm dx=-\int_{\Omega} \mathrm{div}(\nabla u) \, \mathrm dx=-\int_{\partial \Omega} \frac{\partial u}{\partial \eta} \, \mathrm dS=- \int_{\partial \Omega} g \, dS.$$
But I read that the divergence theorem requires compactness of $\Omega$, how is using the theorem justified?