The Stroh formalism is essentially a spatial Hamiltonian formulation and has been recognized to be a powerful tool for solving elasticity problems involving generally anisotropic elastic materials for which conventional methods developed for isotropic materials become intractable. In this paper we develop the Stroh/Hamiltonian formulation for a generally constrained and prestressed elastic material. We derive the corresponding integral representation for the surface-impedance tensor and explain how it can be used, together with a matrix Riccati equation, to calculate the surface-wave speed. The proposed algorithm can deal with any form of constraint, pre-stress, and direction of wave propagation. As an illustration, previously known results are reproduced for surface waves in a pre-stressed incompressible elastic material and an unstressed inextensible fibre-reinforced composite, and an additional example is included analyzing the effects of pre-stress upon surface waves in an inextensible material.