It's common knowledge that the D-Day assaults on the beaches were a horrific "meat grinder" due to Allied troops having to face the suicidal conditions of charging gun emplacements on high ground across an open field with no cover.
As discussed in the comments, this is incorrect. While the Allies predicted high casualties, most of the beaches were a relative a walk over with low casualties. Only Omaha became a meat grinder.
Among the problems at Omaha was an Allied intelligence failure. The Allies expected to meet bodenständig, "static infantry", on the beaches not good for much more than sitting in their fortifications. These units lacked most of the vehicles and heavy weapons of a normal infantry division. They were full of conscripts, old men, and POWs and equipped with a hodge-podge of captured and obsolete weapons. All the good infantry units were behind the beaches to counter attack. Except at Omaha.
The Allies thought Omaha was defended by a single battalion of the weak and inexperienced 716th Static Infantry Division and expected to clear the beaches in just a few hours. Instead it was defended by the much stronger 352nd Infantry Division. With bad intelligence, the Allies did not realize Omaha would need extra support.
And yet for some reason, apparently no one decided "hey, let's use our really big cannons to destroy the meat grinder before deploying our troops, reducing projected casualties by multiple orders of magnitude."
They did try. There was a naval bombardment immediately proceeding the landing, and artillery duels between Allied ships and German shore batteries all day. This illustrates the major duels.
Once the invasion was on, heavy naval units concentrated on the flanks of the invasion to avoid accidentally firing on their own troops. As the day wore on and Omaha looked increasingly desperate, destroyers came inshore to provide close support. USS Frankford famously charged in close, ran along the beach firing at targets of opportunity, then backed up to fire some more. Upon seeing an immobilized tank firing ineffectively at pillboxes, Frankford used them as an impromptu spotter: the tank would fire their 3 inch gun, then Frankford would smother the offending target with rapid 5 inch gunfire.
In addition, several of the more worrying batteries were attacked by US Rangers and British Commandos. Most famously, US 2nd Ranger Battalion scaled the cliffs to attack the guns at Pointe du Hoc only to find they had been moved (the Rangers got them anyway), and the British 9th Parachutte Battallion attacked the Merville Battery only to find the guns were much smaller than expected.
But the troops went in while the guns were still firing. Why?
Naval bombardment wasn't that accurate.
Shore batteries are, unsurprisingly, designed to resist naval bombardment. Thick layers of reinforced concrete and small openings for the guns made them very, very tough targets. They're well camouflaged. And they have an annoying habit of holding their fire to avoid giving away their positions.
Even the Allies knew exactly where the battery is on a map, spotting it is still a challenge. Allies ships don't exactly know their own position, having to pick out their position, as well as the gun battery, from landmarks and through camouflage, smoke, and haze.
In order to effectively engage the guns the navy would need to get in close, and they would need light to see the batteries.
And, in general, the larger the guns, the bigger the ship. Big ships need a lot of water under their keel, have enormous turning circles, and are very slow to change speed. Big ships can't come in very close to the shore or risk grounding right in front of those same guns.
This means waiting until dawn and firing for potentially hours while the rest of the invasion fleet sits and waits. This is a problem because...
The whole invasion was predicated on surprise. Both strategic surprise, fooling the Germans and making them spread themselves thin, but also tactical surprise on the day. It was necessary to keep the Germans from reinforcing Normandy for as long as possible. Unlike overwhelming a small Pacific island, Germany had the whole of Europe to draw reinforcements from. It doesn't matter if the guns are taken out if that gives time for German tanks to show up.
Aerial bombing was common and could be dismissed by the Germans as routine, and the Allies made sure to spread the bombings around for just that reason. Even dropping airborne troops behind the lines the night before left the Germans confused as to whether this was simply a raid or diversion, and again the Allies made every effort to encourage this by dropping dummies along with real soldiers.
But six battleships and twenty-five cruisers showing up at dawn, coming in close, and blasting away is a bit of a give away.
Many gun emplacements did not face the sea
We like to think about gun batteries facing the sea to fire on ships, but many of the batteries didn't face the sea, they fired across the beaches.
In WW2 shore batteries were not terribly effective. The enemy knows where they are. They know roughly the size and range of the guns. They tend to be slow and inaccurate. A modern navy can pick and choose what ships to counter which battery and when. The guns of the Atlantic were a particularly motley collection of whatever the Germans could scrape up, having been called an "artillery museum".
Instead of wasting their time firing on a vast Allied navy, many batteries were designed to fire across the beaches, known as enfilade fire. Their seaward facing side was a slab of concrete.
Here is a fine example of a small battery which is not even visible from the sea. You can see it on the far left halfway up the cliff-face. It's designed specifically to chew up soldiers as they made their way up the beach completely exposed. Soldiers could not fire effectively on the battery without exposing themselves, or conducting a close assault. Because of the horseshoe curve of the beaches, each battery could be covered by other batteries making close assault just as difficult.