Until relatively modern times, cannon placed on ships as weapons were not precision weapons systems. Lashed to the bulkhead to prevent them from becoming "loose cannons," they were directionally aimed, for the most part, by turning the ship on which they were mounted so as to bring the gun to "bear."
A great deal of the skill of a sailing warship's captain involved his ability to maneuver his ship close enough to the enemy to engage while maintaining the ability to break off the engagement and sail out of effective range of the opposing force's guns.
And, while the guns of the 18th century might be capable of tossing a cannon ball almost a mile, truly effective fighting in the age of sail and cannon was at close range 50 -150 yards. Ships were not stationary platforms and sea battles involved problems of time and distance when trying to close an opponent and also the problems of the ship pitching (that's the bow to stern rocking), rolling (side to side rocking) and all the other motions of ships at sea.
In time, various schools of targeting came into existence. As set out here, the English thought was to fire guns on the "down roll" (as the ship rocked down toward the enemy) so as to put holes in the enemy hull - to sink the opponent's ship:
...The British navy's tactics at the time were, in the main, to fire solid shot into the hull of the enemy ship, thus trying to sink it outright.The reason for using the ship's rolling to elevate or depress the aim of the guns was simple- it was easier than trying to wedge the gun in its carriage to effect it elevation.
They used to do this by timing the firing of the guns so that the ship fired its broadside 'on the downroll' ie, when the roll of the ship was such that the guns were aiming lower. This, incidentally, caused enormous casualties on the other side: not from cannonballs piercing the hulls of the enemy ship, but rather from the splinters of wood shooting across the inside of the enemy gundecks whenever the outside of the hull was hit by a cannonball. The French, on the other hand, used much more grapeshot and fired 'on the uproll', aiming for the masts and rigging of their enemies, with the final aim of simply disabling the enemy ship before closing to board and capture it.
So, when watching the following battle scene from Master and Commander at about 33 seconds,listen for the command Captain Aubrey gives to "on the uproll - fire!":
The guns themselves were manpower intensive, as laid out here about USS Constitution:
Each of the gun-deck 24-pounders had its assigned crew of a midshipman and 13 men. This was an unusual arrangement; midshipmen were more usually assigned to duty as assistant division officers or posted on the quarterdeck to relay the captain's orders in the din of battle. In 1812, however, Captain Bainbridge had twenty midshipmen on his strength, and decided to assign most of his young prospective officers to the big guns. Fourteen of Constitution's 15 gundeck 24-pounder crews were commanded by midshipmen; the 15th was in charge of the captain's clerk, who was apparently a versatile individual.See here for the layout of USS Constitution's gun deck.
The gun crew first unfastened the lashings which held the gun secure at sea. This had to be done with care. Gun carriages were not fixed to the deck; if one should break loose in a seaway, the consequences could be dangerous to the ship and fatal to the men who had to bring the massive rolling weight under control. To this day, a dangerously-irresponsible individual is sometimes called a "loose cannon."
The crew now removed the covers that kept dampness out of the bore, and took various gunnery implements from their racks. Guns of this period were equipped with firing locks, but lengths of lighted slow match-cord soaked in an inflammable solution; it burned down slowly, as a lighted cigarette does-were put in safe places along the gun deck for use in case a lock should fail. Down below the frigate's waterline, the gunner and his assistants opened the forward and after magazines and began to break out sausage-shaped flannel powder cartridges for the guns and carronades. Other men took stations along the lower decks to pass cartridges up to the gun crews.
As Constitution drew near to her enemy, all was made ready. The captain took his station on the quarterdeck, from which he could direct the helmsman and order the handling of guns and sails. The marine detachment took their positions with loaded muskets, some on deck and others in the fighting tops. Gun crews checked the loads in their massive weapons and waited in silence for the action to begin.
When Constitution was within reasonable shooting range of her adversary—usually no more than a few hundred yards—the gun-port lids, which kept wind and spray out while cruising, were opened. At the command "run out!" men pulled on the side tackles to roll their guns forward until the muzzles protruded through the ports. One of the gun crew thrust a wire pick through the vent to pierce the cloth powder bag, inserted a priming tube (a length of quill, packed with fine powder) into the vent, and then primed the pan of the firing lock--similar to the locks used in flintlock firearms--with fine powder from a flask or horn. The lock was cocked, and the gun captain--the senior enlisted man of the gun crew--took the end of the firing lanyard and stood, knees flexed, behind the gun and sighted along the barrel.
The captain's order to commence firing was passed by megaphone to the division officers, who then directed their guns. A ship's guns might open fire together in a single broadside, or each division might be ordered to "fire as she bears." As the target came into view through his gun port, the gun captain waited for the proper moment in the ship's roll, depending on whether the object was the enemy's hull or his masts and rigging. At the right moment, the gun captain pulled the lanyard to trip the firing lock. This struck flint against steel, sending a spark into the pan. The ignited powder in the pan sent a flame through the priming tube to set off the powder charge in the gun and hurl its 24-pound iron shot at the enemy with a reverberating thunderclap of sound and a swirl of whitish smoke.