That question has already been answered: Yes, you can. But it is very difficult to do.
You *need* calories to build muscle. Yet to lose fat you need to expend more calories than you take.
It takes a very finely balanced system and *massive* understanding of you own body to do both at the same time effectively.
For the average overweight joe who on any given day does no exercise, and has lots of fat, simply starting a weight lifting routine will see them lose weight and gain (some) muscle. However, that is purely because he is now expending more energy than he was before.
For any guy with a "normal" physique and fitness level, it's much more difficult to do both at the same time -again, not impossible, just difficult.