We derive the shape which a solenoid must have to give, for the smallest possible volume of conductor, the desired value of magnetic field at a pointz0on its axis. To get a somewhat more complete picture of the field produced by the solenoids of such shape we study its behavior away from pointz0in the case of the cylindrical ``frame'' of radiusr0=2 cm and for a few values of the conductor volume.