How to defeat a static army with lots of cannons?
Solution 1:
The formation you describe is in fact of good composition and not easy to defeat.
Before I start, note that you need an army of a certain size to have a chance at all. Attacking with too few troops is just not going to work. I will assume you have at least 60% of his army size.
So first of all, note that his offensive power is almost limited to cannons. Cannons do high damage to tightly packed, slow targets, but are useless against wide-spread, fast units.
I suggest to have your mobile units run around the enemy to form a circle. The main idea is similar to crossing the T, making their artillery less efficient while maximizing your damage output potential once your units are in position.
Make sure your groups have enough distance to each other so the cannons can't do severe damage. You're going to lose part of your forces due to rifles and occasional cannot hits, but the main body will stay intact. Once you're in position and your units are spread wide, open fire and concentrate on the 2 ends of the enemy line, slowly moving closer to the core.
If your army contains horses, have them walk to the back of the enemy forces, then have them dash in to maximize their impact. They should be able to completely suppress or erase enemy rifle fire and potentially destroy parts of the cannon troops as well. Horses are very useful to destroy artillery quickly, so try to bring some along to minimize the damage taken.
Usually, the enemy could anticipate and counter this simple strategy, but due to his immobility he'll fall prey. I'm not aware of any superior general strategy to use against this kind of enemy force.