OpenCV 踩坑之 OpenCV Error: No OpenGL support


当cmake和make编译均通过之后,执行文件时出现该错误


OpenCV Error: No OpenGL support (Library was built without OpenGL support) in CvWindow, 
file /tmp/binarydeb/ros-kinetic-opencv3-3.3.1/modules/highgui/src/window_QT.cpp, line 1642
terminate called after throwing an instance of 'cv::Exception'
what():  /tmp/binarydeb/ros-kinetic-opencv3-3.3.1/modules/highgui/src/window_QT.cpp:1642:
error: (-218) Library was built without OpenGL support in function CvWindow


出现这个问题的原因在于寻找到的 OpenCV模块是不支持 OpenGL的,于是需要在OpenCV模块下的CMakeLists文件中打开对OpenGL的支持。具体操作请参考链接:https://blog.csdn.net/weixin_40198941/article/details/97523485


因为我是之前在安装ROS系统时一起安装了OpenCV模块的,而它恰巧是不支持OpenGL的,所以我也找到了问题的缘由,然而我找不到对应模块下的CMakeLists文件,所以我只好再下载过另一个版本的OpenCV,在cmake编译时加上支持OpenGL的命令。然后在工程中的CMakeLists文件下指定新下载的OpenCV目录即可。



你可能感兴趣的:(错题集)