Solved - Segmentation fault (core dumped) - When running simple OpenCV compiled code

exceptions can be of different types. you aren’t looking to catch an exception of type int, but of type cv::Exception. that is why I gave you this link that shows you exactly what you need:

use whatever version you like. they all can do the basic stuff.