Does every locally compact group $G$ have a nontrivial homomorphism into $\mathbb{R}$? Does every locally compact group (second countable and Hausdorff) topological group $G$ that is not compact have a nontrivial continuous homomorphism into $\mathbb{R}$?
Obviously for compact groups it is not possible since continuous functions send compact sets to compact sets, and there is only one (trivial) compact subgroup of $\mathbb{R}$.

For a connected example one can take $G=\mathrm{SL}_2(\mathbb{R})$ (or any connected simple Lie group). If $f:G\to \mathbb{R}$ is a continuous homomorphism then $f(G)$ is a connected simple subgroup of $\mathbb{R}$, hence trivial.
EDIT: I see now someone already mentioned this in the comments.
