Charge quantization, compactness of the gauge group, and flux quantization