If one of your units is charging an enemy who is touching the other side of an obstacle, the obstacle counts as 'defended'. Measure the charge distance to the obstacle, rather than the enemy unit. Similarly, if the charge is successful, move your unit into contact with the obstacle rather than the unit itself.
Essentially, we assume the enemy push forward to fight over the obstacle – your models count as being in base contact with the enemy behind the obstacle, as if it wasn't there, and must charge in such a way as to maximise the number of models from both sides that can fight, using the normal rules for charging that are presented in the Movement chapter.
To represent the formidable defensive position offered by the obstacle, any models from a charging unit that are in base contact with an obstacle (or are providing supporting attacks for a model in base contact) will suffer penalties depending on the type of obstacle. This modifier only applies when the unit charges, not in subsequent rounds of the combat.
If the charged unit is not in contact with the obstacle, treat it just as you would for the purposes of movement. If there isn't room for a a rank of charging models to fit between the obstacle and the charged unit, it is perfectly acceptable to remove the obstacle whilst the combat goes on (put it back again as soon as possible).