Let $X$ be a compact Riemann surface and $f:X\to\mathbb{C}$ be a holomorphic function. By the local normal form, for each point $p\in X$ there exists a chart $\varphi:U\to V$ in $X$ centered at $p$, and an integer $m$ such that $$f\circ\varphi^{-1}(z)=z^m$$ in a neighborhood of $0$. This integer is called the multiplicity of $f$ at $p$. We will denote it by $\text{Mult}_p(f)$.
We then know that there is only a finite number of points $p$ where $\text{Mult}_p(f)$ is non-zero. Moreover, $$\sum_{p\in X} \text{Mult}_p(f)=0.$$
I also saw some texts saying that the sum of orders of zeros of a holomorphic function in a genus $g$ Riemann surface is equal to $2g-2$. Isn't this sum exactly $$\sum_{p\in X} \text{Mult}_p(f)\:\:\:?$$
I would like to understand exactly what this phrase "the sum of orders of zeros of a holomorphic function in a genus $g$ Riemann surface is equal to $2g-2$" means and, if possible, how to prove it. (If needed, I understand the Riemann-Hurwitz formula.)
Let $X$ be a compact Riemann surface and $M$ its field of meromorphic functions. If $f \in M$ is holomorphic then $f$ must be constant.
Let $h$ be meromorphic non-constant, for most $a\in \Bbb{C}$, $h-a$ has only simple zeros, let $f = \frac{1}{h-a}$ having $N$ simple poles.
Fix a basepoint $p_0\in X$ then $p \mapsto F(p)=\int_{p_0}^p df = f(p)-f(p_0)$ is a branched covering $X \to \Bbb{C}\cup \infty = \Bbb{CP^1}$.
$|F^{-1}(\infty)| = N$, the simplicity of the poles mean all the ramification points are $\in \Bbb{C}$, the Riemann-Hurwitz formula gives $2-2g=\chi(X) = N \chi(\Bbb{CP^1}) - \sum_{p\in X} (e_p-1)= 2N- \sum_{p\in X} (e_p-1)$ so $ \sum_{p\in X} (e_p-1)=2N+2g-2$ where $e_p-1$ is the multiplicity of the zero of $f'(z)$ at $p$, ie. $f'(z)$ has $2N+2g-2$ zeros counted with multiplicity. Since $f'(z)$ also has $N$ double poles, we find it has $2g-2$ more zeros than poles.
Note $f'(z)$ depends on the chosen chart (and it is only defined locally) but its zeros/poles don't depend on the chart, so it makes sense to talk of the global divisor of the local functions $f'(z)$. This is what we mean with the divisor of $df$.
For any meromorphic function $u$ then $u df$ is a meromorphic one-form and since $u$ has the same number of zeros/poles then $udf$ has $2g-2$ more zeros than poles.
Sometimes in every chart $u(z)f'(z)$ is holomorphic : in that case $udf$ is an holomorphic one-form, and since it is a meromorphic one-form with no poles
The complex vector space of holomorphic one-forms is $g$-dimensional, ie. its real dimension is $2g$, making it dual to the homology group $H_1(X,\Bbb{R})$, this is another problem.