  We apply an integral formula obtained by the author for a general
$G$--structure to the case of $G=G_2$. We derive an integral formula relating
curvatures and some quadratic invariants of the endomorphism induced by the
intrinsic torsion. We interpret the formula in certain special cases.
