Let $(a,b)$ be an interval on $\mathbb{R}$. Let $f \in L^1(a,b)$. Assume that $$ \int_a^b f(x)g'(x)\, dx =0 $$ for all $C^1$ functions $g$ with support compactly contained in $(a,b)$. Prove that there is a constant $c$ such that $f(x)=c$ for almost every $x \in (a,b)$.
My thought was to use integration by parts so as to have $$ \int_a^b g(x)df(x)=0 $$ but since $f(x)$ is only integrable, it does not seem to work.
Any help/hint is appreciated!
This is a standard result in calculus of variations (it is a version of the so-called "fundamental lemma").
First of all, by density argument, if the relation holds for every $g\in C^1$ with compact support in $(a,b)$, then it holds also for every $g\in AC$ with $g(a) = g(b) = 0$.
Let $c := \frac{1}{b-a} \int_a^b f$ be the integral mean of $f$, and consider the absolutely continuous function $$ g(x) := \int_a^x [f(t) - c]\, dt, \qquad x\in [a,b]. $$ Clearly $g(a) = 0$ and $g(b) = \int_a^b f - (b-a) c = 0$, so that $g$ can be used as a test function.
We have that $$ \int_a^b (f-c) g' = \int_a^b f g' - c \int_a^b g' = 0. $$ On the other hand $$ \int_a^b (f-c) g' = \int_a^b (f-c)^2, $$ so we can conclude that $f = c$ a.e. in $[a,b]$.