Let $a,b\in\mathbb R$ with $a<b$, $I:=(a,b)$ and $\varphi\in C_c^\infty(I)$.
I would like to show that
- $\exists\psi\in C_c^\infty(I):\varphi=\psi'$;
- $\int_I\varphi=0$
are equivalent.
The direction "$\Rightarrow$" is easy to show. For the other direction, let $$\psi(t):=\int_a^t\varphi(s)\:{\rm d}s\;\;\;\text{for }t\in I.$$ Clearly, $\psi$ is infinitely differentiable and $\psi'=\varphi$. But why does $$0=\int_I\varphi=\psi(b)\tag1$$ imply that $\operatorname{supp}\psi$ is a compact subset of $I$?
Let $a<c<d<b$ be such that the support of $\varphi$ is contained in $[c,d]$. Then $\int_c^d{\varphi}=0$, thus $\psi(x)=0$ if $x \notin [c,d]$.