line bundles and universal covers When dealing with some lifting problems, I came across the following problem, which probably has a well-known answer, but anyway:
Suppose I have a (locally contractible) connected topological group $G$, such that $\pi_1(G) \cong \mathbb{Z}$. Let $\tilde{G} \to G$ be its universal covering group. Let $P \to X$ be a principal $G$-bundle over a compact Hausdorff space $X$. The obstruction of lifting $P$ to a principal $\tilde{G}$-bundle lives in $H^2(X, \pi_1(G)) \cong H^2(X, \mathbb{Z})$ and is therefore given by a complex line bundle over $X$.

Is it possible to construct this line bundle directly from $P$ (without going through the classification of line bundles by their Chern classes)?

 A: I don't think there is a canonical construction of the associated line bundle, this will be only defined up to homotopy, in some sense.
Here is a slightly more geometric construction. Let $G'$ be the group obtained by substituting $\mathbb Z \subseteq \widetilde G$ with $\mathbb R$; that is, $G' = (\widetilde G \times \mathbb R)/\mathbb Z$, with $\mathbb Z$ embedded anti-diagonally. The natural projection $G' \to \widetilde G/\mathbb Z = G$ has kernel $\mathbb R$, hence $P$ will lift to a $G'$-principal bundle $P'$, in a unique fashion, up to isomorphism (but not canonically). Also, $G'$ contains $\widetilde G$ as a normal subgroup, and $G'/\widetilde G \simeq \mathbb R/\mathbb Z \simeq \mathrm S^1$; so $P'$ gives an $\mathrm S^1$ principal bundle, which is the desired obstruction.
A: You can construct a map $\rho:G\to S^1$ by killing the higher homotopy groups of $G$.  As pointed out in the comments to Mark's answer, this may not be a group homomorphism.  However, it will always be an $A_\infty$ map, because it can be delooped to a map $BG\to BS^1$ which classifies a generator of $H^2(BG)$.  Thus we can still use $\rho$ to turn a $G$-bundle into an $S^1$-bundle.
More explicitly, you can construct $\rho$ as follows.  Put a CW-complex structure on $G$.  There will be a copy of $S^1$ sitting inside the 1-skeleton of $G$; let $\rho$ map this to $S^1$ homeomorphically.  By obstruction theory, you can then extend this cell-by-cell to a map on all of $G$.  Given a $G$-bundle on $X$, apply $\rho$ to the transition maps to get "transition maps" for an $S^1$-bundle.  These won't actually be transition maps, because they'll only satisfy the cocycle condition up to homotopy.  However, they satisfy the cocycle condition up to coherent homotopy, so it is possible to strictify them into an actual cocycle.
I don't know a more geometric way of describing it than this, but I would love to see one.
A: Here is my guess as to how this might go.
You want to associate a complex line bundle to the principal $G$-bundle $P\to X$, so you need a $G$-action on the complex numbers, or in other words a continuous homomorphism $G\to \mathbb{C}^\ast$. There is a map $\rho\colon G\to S^1\subseteq\mathbb{C}^\ast$ which classifies the universal covering group, and this can be chosen to be a homomorphism.
Then the line bundle you are after is $P\times_G \mathbb{C} \to X$. 
