[转]OpenCV2.4.12 开启OpenGL启用三维可视化支持

OpenCV默认情况下是不支持OpenGL的,如果要使OpenCV支持OpenGL,则需要重编译,具体步骤如下:

注意事项:从The OpenCV Reference ManualOpenCV参考手册 opencv2refman.pdf [点击下载] 228页来看,OpenGL仅支持32位操作系统;

 

一、准备工作:

(1)下载OpenCV2.4.12 [点击下载]  ,并解压到相应路径,本文解压在 D:\opencv-2.4.12;

(2)下载CMake工具 [点击下载],并安装;

(3)建一个重编译后文件存放文件夹,本文存放在 D:\opencv-2.4.12 build.

 

二、开始重编译:

(1)打开CMake,设置OpenCV2.4.12源码目录及 OpenCV2.4.12编译存放目录,勾选 Advanced 选项,如图:

 

(2)点击 ConfigureSpecify the generator for this project 选择对应的 Visual Studio 版本,比如:我电脑装的是 Visual Studio 2013,故选择 Visual Studio 12 2013,如图所示:

 

然后按 Finish

(3)找到 WHTH_OPENGL ,并打勾,如图:

 

(4)再次点击 Configure,完成之后点击 Generate,结果如下:

 

(5)打开 D:\opencv-2.4.12 build,找到 OpenCV.sln 并双击(使用 Visual Studio 打开);

(6)在 Debug 、Win32 环境下,选择 ALL_BUILD,单击右键,选择 生成,如图:

 

如果提示错误  error LNK1104:无法打开文件“python27_d.lib”,则把 python27_d.lib 下载下来点击打开链接,放在Visual Studio 安装目录下的 VC\lib 文件下即可;然后,重新选择 ALL_BUILD,单击右键,选择 生成即可;

(7)选择 INSTALL,单击右键,选择 生成,如下图:

 

(8)在 Release、Win32 环境下,重复(6)(7)步; 

 

三、Visual Studio环境配置:

(1)点击 属性管理器,分别打开 Debug | Win32 和Release | Win32 下的Microsoft.Cpp.Win32.user ,通用属性 -> VC++ 目录 -> 包含目录 设置为:

D:\opencv-2.4.12 build\install\include
D:\opencv-2.4.12 build\install\include\opencv
D:\opencv-2.4.12 build\install\include\opencv2

通用属性 -> VC++ 目录 -> 库目录 设置为:

D:\opencv-2.4.12 build\install\x86\vc12\lib

如图:

 

(2)链接器 -> 输入 ->附加依赖项,Debug 环境配置为:

 

opencv_calib3d2412d.lib

opencv_contrib2412d.lib

opencv_core2412d.lib

opencv_features2d2412d.lib

opencv_flann2412d.lib

opencv_gpu2412d.lib

opencv_highgui2412d.lib

opencv_imgproc2412d.lib

opencv_legacy2412d.lib

opencv_ml2412d.lib

opencv_nonfree2412d.lib

opencv_objdetect2412d.lib

opencv_ocl2412d.lib

opencv_photo2412d.lib

opencv_stitching2412d.lib

opencv_superres2412d.lib

opencv_ts2412d.lib

opencv_video2412d.lib

opencv_videostab2412d.lib

Release 环境配置为:

 

opencv_calib3d2412.lib

opencv_contrib2412.lib

opencv_core2412.lib

opencv_features2d2412.lib

opencv_flann2412.lib

opencv_gpu2412.lib

opencv_highgui2412.lib

opencv_imgproc2412.lib

opencv_legacy2412.lib

opencv_ml2412.lib

opencv_nonfree2412.lib

opencv_objdetect2412.lib

opencv_ocl2412.lib

opencv_photo2412.lib

opencv_stitching2412.lib

opencv_superres2412.lib

opencv_ts2412.lib

opencv_video2412.lib

opencv_videostab2412.lib

kernel32.lib

user32.lib

gdi32.lib

winspool.lib

comdlg32.lib

advapi32.lib

shell32.lib

ole32.lib

oleaut32.lib

uuid.lib

odbc32.lib

odbccp32.lib

如图:

 

(3)至此配置完成。

 

四、编译时常见错误:

(1)若报如下错误:

错误  2   error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1157    1   opengltest  
错误  6   error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1158    1   opengltest  
错误  12  error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1159    1   opengltest  
错误  17  error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1160    1   opengltest  
错误  23  error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1161    1   opengltest  
错误  29  error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1162    1   opengltest  
错误  35  error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1163    1   opengltest  
错误  41  error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1164    1   opengltest  
错误  47  error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1165    1   opengltest  
错误  53  error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1166    1   opengltest  
错误  59  error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1167    1   opengltest  
错误  65  error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1168    1   opengltest  
错误  71  error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1169    1   opengltest  
错误  77  error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1170    1   opengltest  
错误  83  error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1171    1   opengltest  
错误  89  error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1172    1   opengltest  
错误  95  error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1173    1   opengltest  
错误  101 error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1174    1   opengltest  
错误  107 error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1175    1   opengltest  
错误  113 error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1176    1   opengltest  
错误  119 error C4430: 缺少类型说明符 - 假定为 int。注意:  C++ 不支持默认 int   c:\program files\windows kits\8.1\include\um\gl\gl.h    1177    1   opengltest  
错误  15  error C2371: “APIENTRY”: 重定义;不同的基类型 c:\program files\windows kits\8.1\include\um\gl\gl.h    1159    1   opengltest  
错误  4   error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1157    1   opengltest  
错误  9   error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1158    1   opengltest  
错误  20  error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1160    1   opengltest  
错误  26  error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1161    1   opengltest  
错误  32  error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1162    1   opengltest  
错误  38  error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1163    1   opengltest  
错误  44  error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1164    1   opengltest  
错误  50  error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1165    1   opengltest  
错误  56  error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1166    1   opengltest  
错误  62  error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1167    1   opengltest  
错误  68  error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1168    1   opengltest  
错误  74  error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1169    1   opengltest  
错误  80  error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1170    1   opengltest  
错误  86  error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1171    1   opengltest  
错误  92  error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1172    1   opengltest  
错误  98  error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1173    1   opengltest  
错误  104 error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1174    1   opengltest  
错误  110 error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1175    1   opengltest  
错误  116 error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1176    1   opengltest  
错误  122 error C2182: “APIENTRY”: 非法使用“void”类型   c:\program files\windows kits\8.1\include\um\gl\gl.h    1177    1   opengltest  
错误  121 error C2146: 语法错误: 缺少“;”(在标识符“glColor3dv”的前面)   c:\program files\windows kits\8.1\include\um\gl\gl.h    1177    1   opengltest  
错误  115 error C2146: 语法错误: 缺少“;”(在标识符“glColor3d”的前面)    c:\program files\windows kits\8.1\include\um\gl\gl.h    1176    1   opengltest  
错误  109 error C2146: 语法错误: 缺少“;”(在标识符“glColor3bv”的前面)   c:\program files\windows kits\8.1\include\um\gl\gl.h    1175    1   opengltest  
错误  103 error C2146: 语法错误: 缺少“;”(在标识符“glColor3b”的前面)    c:\program files\windows kits\8.1\include\um\gl\gl.h    1174    1   opengltest  
错误  97  error C2146: 语法错误: 缺少“;”(在标识符“glClipPlane”的前面)  c:\program files\windows kits\8.1\include\um\gl\gl.h    1173    1   opengltest  
错误  91  error C2146: 语法错误: 缺少“;”(在标识符“glClearStencil”的前面)   c:\program files\windows kits\8.1\include\um\gl\gl.h    1172    1   opengltest  
错误  85  error C2146: 语法错误: 缺少“;”(在标识符“glClearIndex”的前面) c:\program files\windows kits\8.1\include\um\gl\gl.h    1171    1   opengltest  
错误  79  error C2146: 语法错误: 缺少“;”(在标识符“glClearDepth”的前面) c:\program files\windows kits\8.1\include\um\gl\gl.h    1170    1   opengltest  
错误  73  error C2146: 语法错误: 缺少“;”(在标识符“glClearColor”的前面) c:\program files\windows kits\8.1\include\um\gl\gl.h    1169    1   opengltest  
错误  67  error C2146: 语法错误: 缺少“;”(在标识符“glClearAccum”的前面) c:\program files\windows kits\8.1\include\um\gl\gl.h    1168    1   opengltest  
错误  61  error C2146: 语法错误: 缺少“;”(在标识符“glClear”的前面)  c:\program files\windows kits\8.1\include\um\gl\gl.h    1167    1   opengltest  
错误  55  error C2146: 语法错误: 缺少“;”(在标识符“glCallLists”的前面)  c:\program files\windows kits\8.1\include\um\gl\gl.h    1166    1   opengltest  
错误  49  error C2146: 语法错误: 缺少“;”(在标识符“glCallList”的前面)   c:\program files\windows kits\8.1\include\um\gl\gl.h    1165    1   opengltest  
错误  11  error C2146: 语法错误: 缺少“;”(在标识符“GLboolean”的前面)    c:\program files\windows kits\8.1\include\um\gl\gl.h    1159    1   opengltest  
错误  43  error C2146: 语法错误: 缺少“;”(在标识符“glBlendFunc”的前面)  c:\program files\windows kits\8.1\include\um\gl\gl.h    1164    1   opengltest  
错误  37  error C2146: 语法错误: 缺少“;”(在标识符“glBitmap”的前面) c:\program files\windows kits\8.1\include\um\gl\gl.h    1163    1   opengltest  
错误  31  error C2146: 语法错误: 缺少“;”(在标识符“glBindTexture”的前面)    c:\program files\windows kits\8.1\include\um\gl\gl.h    1162    1   opengltest  
错误  25  error C2146: 语法错误: 缺少“;”(在标识符“glBegin”的前面)  c:\program files\windows kits\8.1\include\um\gl\gl.h    1161    1   opengltest  
错误  19  error C2146: 语法错误: 缺少“;”(在标识符“glArrayElement”的前面)   c:\program files\windows kits\8.1\include\um\gl\gl.h    1160    1   opengltest  
错误  14  error C2146: 语法错误: 缺少“;”(在标识符“glAreTexturesResident”的前面)    c:\program files\windows kits\8.1\include\um\gl\gl.h    1159    1   opengltest  
错误  8   error C2146: 语法错误: 缺少“;”(在标识符“glAlphaFunc”的前面)  c:\program files\windows kits\8.1\include\um\gl\gl.h    1158    1   opengltest  
错误  3   error C2146: 语法错误: 缺少“;”(在标识符“glAccum”的前面)  c:\program files\windows kits\8.1\include\um\gl\gl.h    1157    1   opengltest  
错误  1   error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1157    1   opengltest  
错误  5   error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1158    1   opengltest  
错误  16  error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1160    1   opengltest  
错误  22  error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1161    1   opengltest  
错误  28  error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1162    1   opengltest  
错误  34  error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1163    1   opengltest  
错误  40  error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1164    1   opengltest  
错误  46  error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1165    1   opengltest  
错误  52  error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1166    1   opengltest  
错误  58  error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1167    1   opengltest  
错误  64  error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1168    1   opengltest  
错误  70  error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1169    1   opengltest  
错误  76  error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1170    1   opengltest  
错误  82  error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1171    1   opengltest  
错误  88  error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1172    1   opengltest  
错误  94  error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1173    1   opengltest  
错误  100 error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1174    1   opengltest  
错误  106 error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1175    1   opengltest  
错误  112 error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1176    1   opengltest  
错误  118 error C2144: 语法错误:“void”的前面应有“;”    c:\program files\windows kits\8.1\include\um\gl\gl.h    1177    1   opengltest  
错误  7   error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1158    1   opengltest  
错误  13  error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1159    1   opengltest  
错误  18  error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1160    1   opengltest  
错误  24  error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1161    1   opengltest  
错误  30  error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1162    1   opengltest  
错误  36  error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1163    1   opengltest  
错误  42  error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1164    1   opengltest  
错误  48  error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1165    1   opengltest  
错误  54  error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1166    1   opengltest  
错误  60  error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1167    1   opengltest  
错误  66  error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1168    1   opengltest  
错误  72  error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1169    1   opengltest  
错误  78  error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1170    1   opengltest  
错误  84  error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1171    1   opengltest  
错误  90  error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1172    1   opengltest  
错误  96  error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1173    1   opengltest  
错误  102 error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1174    1   opengltest  
错误  108 error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1175    1   opengltest  
错误  114 error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1176    1   opengltest  
错误  120 error C2086: “int WINGDIAPI”: 重定义   c:\program files\windows kits\8.1\include\um\gl\gl.h    1177    1   opengltest  
错误  10  error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1158    1   opengltest  
错误  21  error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1160    1   opengltest  
错误  27  error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1161    1   opengltest  
错误  33  error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1162    1   opengltest  
错误  39  error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1163    1   opengltest  
错误  45  error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1164    1   opengltest  
错误  51  error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1165    1   opengltest  
错误  57  error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1166    1   opengltest  
错误  63  error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1167    1   opengltest  
错误  69  error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1168    1   opengltest  
错误  75  error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1169    1   opengltest  
错误  81  error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1170    1   opengltest  
错误  87  error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1171    1   opengltest  
错误  93  error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1172    1   opengltest  
错误  99  error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1173    1   opengltest  
错误  105 error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1174    1   opengltest  
错误  111 error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1175    1   opengltest  
错误  117 error C2086: “int APIENTRY”: 重定义    c:\program files\windows kits\8.1\include\um\gl\gl.h    1176    1   opengltest  
错误  123 error C1003: 错误计数超过 100;正在停止编译  c:\program files\windows kits\8.1\include\um\gl\gl.h    1177    1   opengltest  

则在 GL.h 文件下,添加 #include <windows.h> 头文件即可;

如图:

 

(2)若报如下错误:

错误  5   error LNK2019: 无法解析的外部符号 __imp__glRectf@16,该符号在函数 "void __cdecl onDraw(void *)" (?onDraw@@YAXPAX@Z) 中被引用    F:\VS2013 program\opengltest\opengltest\opengltest.obj  opengltest  
错误  4   error LNK2019: 无法解析的外部符号 __imp__glFlush@0,该符号在函数 "void __cdecl onDraw(void *)" (?onDraw@@YAXPAX@Z) 中被引用 F:\VS2013 program\opengltest\opengltest\opengltest.obj  opengltest  
错误  3   error LNK2019: 无法解析的外部符号 __imp__glColor3f@12,该符号在函数 "void __cdecl onDraw(void *)" (?onDraw@@YAXPAX@Z) 中被引用  F:\VS2013 program\opengltest\opengltest\opengltest.obj  opengltest  
错误  2   error LNK2019: 无法解析的外部符号 __imp__glClearColor@16,该符号在函数 "void __cdecl onDraw(void *)" (?onDraw@@YAXPAX@Z) 中被引用   F:\VS2013 program\opengltest\opengltest\opengltest.obj  opengltest  
错误  1   error LNK2019: 无法解析的外部符号 __imp__glClear@4,该符号在函数 "void __cdecl onDraw(void *)" (?onDraw@@YAXPAX@Z) 中被引用 F:\VS2013 program\opengltest\opengltest\opengltest.obj  opengltest  
错误  6   error LNK1120: 5 个无法解析的外部命令 F:\VS2013 program\opengltest\Debug\opengltest.exe   opengltest  
则在 main 函数所在文件下添加 #pragma comment(lib,"opengl32.lib") 即可;
 
(3)若编译成功,在 cmd终端 运行时报错为“OpenCV Error: No OpenGL support (Library was built without OpenGL support) ……”,则把编译前的文件删除即可,即把 D:\opencv-2.4.12 文件夹删除即可;
 
posted @ 2018-05-21 15:58  rainbow70626  阅读(1235)  评论(0编辑  收藏  举报