We prove a result that relates the number of homomorphisms from the fundamental group of a compact nonorientable surface to a finite group G, where conjugacy classes of the boundary components of the surface must map to prescribed conjugacy classes in G, to a sum over values of irreducible characters of G weighted by Frobenius-Schur multipliers. The proof is structured so that the corresponding results for closed and possibly orientable surfaces, as well as some generalizations, are derived using the same methods. We then apply these results to the specific case of the symmetric group.