In this paper, we describe how the swimming of linked-rigid bodies can be simulated using smoothed particle hydrodynamics (SPH). The fluid is assumed to be viscous and weakly compressible though with a speed of sound which ensures the Mach number is ∼0.1 and the density fluctuation (relative to the average density) is typically 0.01. The motion is assumed to be two-dimensional. The boundaries of the rigid bodies are replaced by boundary particles and the forces between these particles and the fluid particles determine the forces and torques on the rigid bodies. The links between the bodies are described by constraint equations which are taken into account by Lagrange multipliers. We integrate the equations by a second-order method which conserves linear momentum exactly and, in the absence of viscosity, is reversible. We test our method by simulating the motion of a cylinder moving in a viscous fluid both under forced oscillation, and when tethered to a spring. We then apply our method to three problems involving three linked bodies. The first of these consists of three linked diamonds in a periodic domain and shows the convergence of the algorithm. The second is the system considered by Kanso et al. [E. Kanso, J.E. Marsden, C.W. Rowley, J.B. Melli-Huber, Locomotion of articulated bodies in a perfect fluid, J. Nonlinear Sci. 15 (2005) 255–289 (referred to in the text as K05)] and our results show similar behaviour for the same gait. The third example clarifies the conservation of angular momentum by simulating the motion of three linked ellipses moving within and through the surface of an initially circular patch of fluid. Our method can be easily extended to linked bodies swimming near surfaces, or to swimming near fixed boundaries of arbitrary shape, or to swimming in fluids which are stratified. Some of these systems have biological significance and others are applicable to the study of undersea vessels which move because of shape changes.