I am looking for a reference for the fact that the top cohomology $H^n(X;A)$ of an $n$-dimensional manifold $X$ is non-trivial precisely when $X$ is compact.

I tried to ask this question on Math.Stackexchange, but there was some issue regarding orientability.

If $X$ is orientable, this should follow from standard Poincaré duality, but in my understanding the assumption of orientability can be removed by using "twisted" Poincaré duality. In this case, the coefficients must be local for $H^n$ to be non-trivial. (Edit: They don't need to be local, see the answer by Johannes Ebert below.) But if the coefficients respect the orientation (i.e. the coefficients are a constant sheaf, which is twisted by the orientation character), then $H^n\neq0$ if and only if $X$ is compact.

I vaguely remember hearing about an isomorphism $H^n\cong H_c^0$, where $H_c^\ast$ denotes compactly supported cohomology. The argument then goes that $H_c^0$ is non-trivial precisely when $X$ is non-compact, which I think of by using covers in Čech cohomology. $0$th cohomology with values in the sheaf of locally constant functions is just constant functions on all open sets of the cover $\{U_i\}$ and these functions must agree on single intersections $U_i\cap U_j$. The cohomology classes are thus given by globally constant functions, which, for compactly supported cohomology can only be the zero function when $X$ is non-compact, and can be any constant function when $X$ is compact.

It seems this argument makes no use of orientability, provided, there exists a twisted version of $H^n\cong H_c^0$...

4more comments