In this paper, the piezoelectric compensation of torsional vibrations in rods caused by external excitations is studied. As an illustrative example, a laminated rod containing piezoelectric shear actuators is assumed to be fixed at the one end, and the other end is subjected to a torsional couple; additionally, a distributed torsional couple per unit length is acting. In such a system, cross-sectional warping is known to be present. The consideration of piezoelectric eigenstrains requires an extension of Saint Venant's theory of torsion, which is achieved by introducing an additional warping function. Using D'Alembert's principle, the boundary value problems for Saint Venant's warping function, the additional warping function and the torsional angle are obtained. From the latter boundary value problems, the distribution of piezoelectric actuation is derived in order to completely compensate the external excitations, i.e. an analytical solution of the corresponding shape control problem is obtained. Finally, the results are verified by means of three-dimensional finite element computations.