They build it on the ground, raise it up with another crane, and then lift the counter weights up!
Usually another crane is used to hoist modular sections an erect the crane. Some large construction cranes build themselves using modular tower sections. The boom and crane cab lifts itself on a track, the crane lifts a modular section of tower from the ground, and inserts it under the cab. The top lifts itself up and starts again. Check out the video below. Incidentally, enormous blocks of concrete are poured on the ground to support cranes like this one, and are too massive to remove when construction is complete. So, many tall buildings have huge monolithic hunks of concrete in the ground at their base....