It is unlikely glue will remove the cactus thorn. Try to use tweezers if you can see or feel the edge of the cactus needle. It often helps soaking the foot in warm water or Epsom Salt. Seek veterinary medical attention if you are unable to remove the cactus needle on your own. If it is not removed this area will become very painful and infected.
I saw a trick the other night on television on a show called Royal Pains. The doctor took some rubber glue and poured it on the patients hand. The patient had big torns sticking out of the side of his hand. They let the glue dry and the doctor peeled the glue off and the torns came with it. Made sense to me. The only other solution is to take your dog to the vet.