On the generalized Gauss-Bonnet theorem I am trying to learn about basic characteristic classes and Generalized Gauss-Bonnet Theorem, and my main reference at the moment is From calculus to cohomology by Madsen & Tornehave. I know the statement of the theorem is as follows:

Let $M$ be an even-dimensional compact, oriented smooth manifold, $F^{∇}$ be the curvature of the connection ∇ on a smooth vector bundle $E$.
$$∫_{M}\mathrm{Pf}\Big(\frac{−F^{∇}}{2\pi}\Big)=χ(M^{2n}).$$

My questions are:

*

*How does this relate to counting (with multiplicities) the number of zeros of generic sections of the vector bundle?

*Also, are there other good references for learning this topic?

 A: Maybe what follows is not exactly what you are looking for, but it gives you an answer at least when you don't want to restrict yourself to the tangent bundle and work rather with general (complex) vector bundles.
All that I write you can find on "Principle of algebraic geometry", by Griffiths and Harris.
Let $M$ be a compact, oriented manifold, $E\to M$ a complex vector bundle of rank $k$ and $\sigma=(\sigma_1,\dots,\sigma_k)$ $k$ global smooth sections of $E$. Define the degeneracy set $D_i(\sigma)$ to be the set of points $x\in M$ where $\sigma_1,\dots\sigma_i$ are linearly dependent, that is
$$
D_i(\sigma)=\{x\mid\sigma_1(x)\wedge\cdots\wedge\sigma_i(x)=0\}.
$$
One says that the collection $\sigma$ is generic if, for each $i$, $\sigma_{i+1}$ intersects the subspace of $E$ spanned by $\sigma_1,\dots,\sigma_i$ transversely and if moreover the integration over $D_{i+1}(\sigma)\setminus D_i(\sigma)$ defines a closed current.
This happens, for instance, if everything is complex analytic and the dimensions are the expected ones.
Now, suppose that $\sigma_1,\dots,\sigma_k$ are generic sections of $E$. Then, the Gauss-Bonnet Formula reads:
The $r$th Chern class $c_r(E)$ is Poincaré dual to the degeneracy cycle $D_{k-r+1}$.
In particular, suppose that $M$ is of even dimension $2k$. Then, the top Chern class $c_k(E)\in H^{2k}(M,\mathbb Z)\simeq\mathbb Z$. If $\sigma$ is a smooth section of $E$ having non-degenerate zeros, then the integer $c_k(E)$ counts precisely these zeros (with sign, depending on orientations), which compose the degeneracy cycle $D_1$. 
Finally, to recover the top Chern class of $E$ from its differential-geometric data, just recall that the Chern forms $c_r(E,\nabla)$ of a vector bundle $E$ endowed with a connection $\nabla$ are defined by the formula
$$
\det(I+t\Theta(E,\nabla))=1+tc_1(E,\nabla)+\cdots+t^kc_k(E,\nabla),
$$
where $\Theta(E,\nabla)$ is the curvature of the connection $\nabla$.
Then your integral quantity is given by 
$$
\int_M c_k(E,\nabla).
$$
Specializing further, if $M$ is a compact complex manifold of dimension $k$ and $E=T_M$ its holomorphic tangent bundle, then
$$
c_k(T_M)=c_k(M)=\chi_{\text{top}}(M).
$$     
A: I'll make some general remarks. One may break down the generalized Gauss-Bonnet into two parts.
The first is to verify that it is a topological invariant. This means that
it should be independent of the Riemannian metric. So one needs to see that
for a 1-parameter family of metrics on $M$ (or corresponding connections),
the integral on the left does not change. I don't have a good reason why
this is, but I think it can be boiled down to an application of Stokes theorem
(this is certainly true in the proof of the classic Gauss-Bonnet theorem).
Assuming topological invariance (independence of the metric), then
one needs to check that the topological invariant it defines is the
Euler characteristic. One may check that it satisfies the
same axioms as the Euler characteristic (up to an overall multiplication
by a constant). Once you've checked this, then it follows that it is
the Euler characteristic. Let $P(M)$ be the Pfaffian integral over $M$ (which we
are assuming is a topological invariant, i.e. metric independent). 
Consider a smooth manifold with boundary $M$. Choose a metric on $M$ which
is a product near the boundary. Then the Pfaffian integral over $M$ is
a topological invariant, since the integral over the double of $M$ is
independent of the metric. Call this invariant $P(M)$ too. If we choose $M_1$ and $M_2$ with
an identification between $\partial M_1\cong \partial M_2$, choose
equivalent metrics on $\partial M_1$ and $\partial M_2$ with product collars near the boundary, then glue $W=M_1 \cup_{\partial M_1=\partial M_2} M_2$ to
get a closed manifold. Clearly $P(W)=P(M_1)+P(M_2)$. So this invariant
is additive under gluing (one also sees that it is additive under
gluing along components of the boundary). Notice also that for a $2n-1$ manifold $K$,
$P(K\times [0,1])=0$. This is because $2P(K\times S^1)=P(K\times S^1)=P(K\times I)$
since one may take the 2-fold self-cover $K\times S^1\to K\times S^1$,
which decomposes into two copies of $K\times S^1$. 
Now, consider a Morse function $f$ on $M$. Break $M$ up into elementary
bordisms by taking intervals $[a_i,a_{i+1}]$ such that each interval contains
precisely one critical value of $f$. One sees that for the index $0$ and $n$ bordisms $B$, 
$P(B)=P(B^{2n})$ the ball. When one amalgamates an index $i$ bordism $B_i$
with and index $i+1$ bordism $B_{i+1}$, then one may arrange that the index $i$ and $i+1$ handles cancel to give a product bordism. So $P(B_i)+P(B_{i-1}) =0$. From
this, one obtains the formula that $P(M)$ is a sum of the signs of the
indices of the critical points of a Morse function (multiplied by $P(B^{2n})$), and therefore gives
the Euler characteristic.
So we have determined that $P(M)$ is proportional to the Euler characteristic using only its independence of the Riemannian metric. 
A: Mathai and Quillen have a theorem that computes the Euler characteristic as an integral of a form defined using a section of and a connection on the tangent bundle. If one scales the section by a factor $t$, then at $t=0$ one gets the Gauss-Bonnet theorem, and as $t\to\infty$ the integral localizes near the zero set of the section and becomes the Poincar\'e-Hopf theorem. 
A: When $E\to M$ is an oriented vector bundle of rank $2n$ over a 
compact manifold $M$, it has a well-defined de Rham Euler class $e(E)$ 
in $H^{2n}_{dR}(M)$, and a representative $2n$-form for $e(E)$ 
can be computed as follows:  
Fix a positive definite inner product $\langle,\rangle$ on $E$. (Since any two such inner products are equivalent under automorphisms of $E$, it doesn't matter which one.)  Let $\nabla$ be a $\langle,\rangle$-orthogonal connection on $E$, and let $K^\nabla$ denote the curvature of $\nabla$, regarded as a $2$-form with values in ${\frak{so}}(E)$.  Let $e(\nabla) = \mathrm{Pf}(K^\nabla/2\pi)$, which is a well-defined $2n$-form on $M$. (N.B.: The definition of $\mathrm{Pf}$ requires both the inner product and the orientation of $E$.)  Then $e(E)=\bigl[e(\nabla)\bigr]\in H^{2n}_{dR}(M)$. (That $\bigl[e(\nabla)\bigr]$ is independent of the choice of $\nabla$ 
is one of the first results proved in Chern-Weil theory.)
If $M$ is a compact, oriented $2n$-manifold, then the value of $e(E)$ on $[M]$, the fundamental class of $M$, can be computed as follows:  Let $Y$ be a section of $E$ that has only a finite number of zeroes.  (By Whitney transversality, the generic section of $E$ satisfies this condition.)  Using the orientations of $E$ and $M$, one defines the index 
of an isolated zero $z$ of $Y$, which is an integer $\iota_Y(z)$.  Then
$$
e(E)\bigl([M]\bigr) = \int_M e(\nabla) = \sum_{z\in Z}\ \iota_Y(z).
$$
By the Poincaré-Hopf Theorem, when $E = TM$ (as oriented bundles), 
this sum is equal to the Euler characteristic of $M$, which explains
why $e(E)$ is called the Euler class of $E$.
To prove this result, one chooses an orthogonal connection $\nabla$ on $E$ that depends on $Y$ and whose Euler form $e(\nabla)$ is easy to evaluate explicitly.  This can be done as follows:  
Let $Z\subset M$ be the (finite) zero set of $Y$ and let $U\subset M$ be an open neighborhood of $Z$ that consists of disjoint, smoothly embedded $2n$-balls, one around each element of $Z$.  Let $\phi$ be a smooth function on $M$ that is identically equal to $1$ on an open neighborhood of $Z$ and whose support $K\subset U$ is a disjoint union of closed, smoothly embedded balls, 
one around each element of $Z$. 
Now, $E$ is trivial over $U$, 
so choose a positively oriented $\langle,\rangle$-orthonormal basis of sections 
$s_1,\ldots, s_{2n}$ of $E$ over $U$ and let $\nabla_1$ be the (flat) connection on $E_U$ for which these sections are parallel.  Let $\bar Y = Y/|Y|$ be the normalized unit section defined on $M\setminus Z$, and define a second connection on $U$ by
$$
\nabla_2 s  =  \nabla_1 s 
+ (1{-}\phi)\bigl( \bar Y\otimes \langle s,\nabla_1 \bar Y\ \rangle
- \langle s,\bar Y\ \rangle\ \nabla_1\bar Y\ \bigr).
$$
It is easily verified that this formula does define a connection on $U$, 
that $\nabla_2$ is $\langle,\rangle$-orthogonal, and that,
outside of $K$ (i.e., where $\phi\equiv0$), the vector field $\bar Y$ is 
$\nabla_2$-parallel.  (Note that, because $\phi\equiv1$ near $Z$, where $Y$ is
not defined, this formula does extend smoothly across $Z$, agreeing with $\nabla_1$
on a neighborhood of $Z$.)
Meanwhile, on $M\setminus K$, write $E$ as a $\langle,\rangle$-orthogonal direct sum $E = \mathbb{R}\cdot Y \oplus E'$ and choose a $\langle,\rangle$-compatible connection $\nabla_3$ on $E$ over $M\setminus K$ that preserves this splitting.  Using a partition of unity subordinate to the open cover of $M$ defined by $U$ and $M\setminus K$, construct a $\langle,\rangle$-orthogonal connection $\nabla$ that agrees with $\nabla_2$ on $K$ and with $\nabla_3$ on $M\setminus U$, and for which the line bundle $\mathbb{R}\cdot Y\subset E$
is parallel on $M\setminus K$.
Now, on $M\setminus K$, the curvature of $\nabla$ takes values in ${\frak{so}}(E')\subset{\frak{so}}(E)$, so $e(\nabla) = \textrm{Pf}\bigl(K^{\nabla}/(2\pi)\bigr)$ vanishes identically outside of $K$.  It suffices now to evaluate the
integral of $e(\nabla)$ over a single component $B$ of $K$, which may be 
assumed to be the unit ball in $\mathbb{R}^{2n}$, so restrict attention to
this case.  Write $\bar Y = s_1 u_1 +\cdots + s_{2n}\ u_{2n}$, and note that,
on $B$, one has, by definition,
$$
\nabla s_i = \nabla_2 s_i 
= \sum_{j=1}^{2n} s_j\otimes (1{-}\phi)(u_j\ du_i - u_i\ du_j),
$$
i.e., the connection $1$-forms of $\nabla$ in this basis are 
$\omega_{ij} = (1{-}\phi)(u_i\ du_j - u_j\ du_i)$.
Using the identity ${u_1}^2 +\cdots + {u_{2n}}^2 = 1$, 
the curvature forms are easily computed to satisfy
$$
\Omega_{ij} = d\omega_{ij} + \omega_{ik}\wedge\omega_{kj}
= (1{-}\phi^2)\ du_i\wedge du_j - d\phi\wedge(u_i\ du_j - u_j\ du_i).
$$
At this point, you have to know the definition of the Pfaffian.  (I'll wait while you look it up.)  Using the fact that the result has to be invariant under $SO(2n)$-rotations, it is easy to show that, on $B$, one has
$$
e(\nabla) = \textrm{Pf}\left(\frac{\Omega}{2\pi}\right)
= c_n (1{-}\phi^2)^{n-1} d\phi\wedge u^*(\Upsilon)
$$
for some universal constant $c_n$ and where $\Upsilon$ is the $SO(2n)$-invariant $2n$-form 
of unit volume on $S^{2n-1}\subset\mathbb{R}^{2n}$ and $u: B\setminus z\to S^{2n-1}$
is $u = (u_1,\ldots, u_{2n})$.  (I'll let you evaluate the constant $c_n$.  This can be done in a number of ways, but it's essentially a combinatorial exercise.)  In particular, 
$$
e(\nabla) = d\bigl(P_n(1{-}\phi)\ u^*(\Upsilon)\bigr) 
$$
where $P_n(t)$ is the polynomial in $t$ (of degree $2n{-}1)$) that vanishes at $t=0$ and 
satisfies $P'_n(1{-}t) = -c_n(1{-}t^2)^{n-1}$.  By Stokes' Theorem, one has
$$
\int_B e(\nabla) = P_n(1) \int_{\partial B}u^*(\Upsilon) 
 = P_n(1)\ \textrm{deg}(u:\partial B\to S^{2n-1}) = P_n(1)\ \iota_Y(z)
$$
Thus, it follows that there is a universal constant $C_n = P_n(1)$ such that
$$
e(E)\bigl([M]\bigr) = \int_M e(\nabla) = C_n \ \sum_{z\in Z}\ \iota_Y(z).
$$
Now, $C_1 = 1$, as one can show by computing with the constant curvature metric on the $2$-sphere and noting that, for $Y$ the gradient of the height function on $S^2$, the sum of the indices is $2$.  Finally, by properties of the Pfaffian and the index, one sees that,
if such a formula as above is to hold, then one must have $C_{n+m}=C_nC_m$.  Thus, $C_n=1$ for all $n$, and the formula is proved.
(Of course, one can avoid these final tricks for evaluating the constants by carefully doing the combinatorial exercise, but I'll leave that to the curious.)
A: You can try  Chap. 13, vol. 5 of M. Spivak's  opus   A comprehensive  Introduction to Differential Geometry. (On the cover of this volume there  are three birds  carrying a banner that reads  "All the way with Gauss Bonnet")
Also you can try my book    Lectures on the geometry of manifolds  where  I discuss many approaches to this theorem and connections to other problems in geometry.     
For  a really gentle introduction  to  this theorem I would also recommend  the  small survey paper  The many faces of Gauss-Bonnet which  is a talk that I gave to first year graduate students a few years ago.  It contains many figures and plenty of  other references.
