Time on the saddle is the best way to build up your legs. Training with some hill repeats can help build strength.
Another bit of advice is to watch what gears you use when riding. Spinning at a lower gear will help save your legs. Your post seems to indicate that you may be grinding in too high of a gear causing fatigue. Do a search on this forum on cadence and you will get lots of good advice.