You make sure all strings are pressed down nicely, and it hurts...and you practice it regularly until your hands get used to doing it. After a while, your hands will stretch more easily, they'll remember the positions they're supposed to go in, and it doesn't hurt so much.

Barre chords are most difficult on a steel stringed acoustic guitar...they feel much easier (and more useful) on an electric guitar.

You'll probably find you don't use barre chord so much when playing acoustic. There are a lot of other ways to play most chords higher up the neck using only a few fingers along with some open strings.

Good luck--I know it hurts! But a little pain never hurt anyone.