First time here? Check out the FAQ!
Link following libraries and it should work g++ webcam.cpp -o objDetection -lopencv_core -lopencv_imgproc -lopencv_objdetect -lopencv_highgui