There are various ways of fixing gauge issues, but -- assuming it's a relatively non-complicated pattern (i.e. not a lace pattern or solid cabling) -- you can just adjust the math.
The gauge is 4 sts per inch. Take the number of stitches it tells you to cast on; divide by 4 to get the number of inches you're casting on. Figure out how many stitches per inch you're getting in your swatch, multiply that by the number you got before, and there's your CO number.
You may also have to do some fudging when it comes to decreases, since you'll have a different number of stitches to decrease, but some patterns that's fairly easy.
...vertical (row) gauge doesn't usually matter so much, since a lot of patterns do "knit for 6 inches" rather than "knit for 24 rows", and so you can do however many rows that takes. (so if you find a needle+yarn combo that hits the horizontal gauge [stitches per inch] but not the vertical gauge [rows per inch], go with that and don't worry about it.)