I understand your question is about the mechanism between the main shaft of the engine and the accessory box, mechanism which is also used to start the engine and turn spool during inspection.
This pertains to the HP (IP) spool, as the LP spool is easily turned using the fan which is freely accessible.
I used images from a very good book on engines: The Jet Engine, Rolls Royce
While there are different solutions, the widely used one consists in one or more shafts perpendicular to the high pressure spool (intermediate spool for a Rolls-Royce 3-spool engine) and linked to the latter by a gearbox.
Such driveshaft is known as a radial (or tower) driveshaft.
Radial shaft linked to the intermediate spool in the compressor section
The details of the gearbox between the radial shaft and the shaft may vary:
The other end of the radial driveshaft drives the accessory box using a second gearbox and a driven shaft:
The starter is, as are the accessories, connected to this driven shaft. This allows for the starter to run the spool when starting the engine.
When the engine is not running, the spool can be rotated for inspection by turning another shaft and a reduction gearbox (to facilitate manual rotation). This additional shaft can be accessible from the outside after removing a panel (as it is on the last figure, look for "engine hand-turn access" on the right side).
Actual design may vary, but the principle is common. An overall view of the very used CFM56-7 turbofan:
Radial shaft linked to the spool. Source