Give him time. It can be a little scary for a kid to poop somewhere other than his diaper. The most important thing is to be positive and encourage any progress (even if it's just sitting on the potty). Make sure he's got plenty of fiber and water in his diet, as constipation will only make things worse. If he uses a toilet, get one of those seats that fit on top of the regular seat (so he won't fall in) and have a step stool or something handy for him to rest his feet on (it helps with pushing).
My eldest was just like this (luckily, she always pooped at night, so it wasn't a problem with preschool). What finally did it was the promise that she could pick out a special prize at the mall if she pooped in the potty. She ended up picking out a dime-store bracelet -- if I'd known it was going to be that cheap and easy, I would have bought bunches of them months before!
Claire McCarthy, M.D., is an assistant professor of pediatrics at Harvard Medical School in Boston. Send her your health questions at Parenting.com/momsquad.