Since the forces at the pin joints between the links have no relative displacement associated with them, they do no work on the system, and thus will not appear in the work equation. The work done by the system plus losses is equal to the energy delivered to the system.