For a general class of robots with elastic joints, we introduce an inversion algorithm for the synthesis of a dynamic feedback control law that gives input-output decoupling and full state linearization. Control design is performed directly on the second-order robot dynamic equations. The linearizing control law is expressed in terms of the original model components and of their time derivatives, allowing an eficient organization of computations. A tight upper bound for the dimension of the needed dynamic compensator is also obtained.