Generally, you want the dog to have to strain when they have anal gland issues because this will help to empty the gland. However, once a gland becomes impacted, it can be painful. If this is the case in your dog, you can soften the stool by adding 1 tsp of canned pumpkin (not pie filling) to his next few meals. This will have gentle effect.
Then see your vet tomorrow.
Let me know if you still have questions.