opencv3.2.0 Cmake 3.8.0 编译问题
Posted 方豆
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了opencv3.2.0 Cmake 3.8.0 编译问题相关的知识,希望对你有一定的参考价值。
opencv3.2.0 Cmake 3.8.0 TDM-GCC 5.1.0
Windows 7 遇到如下错误
[ 53%] Building CXX object modules/world/CMakeFiles/opencv_world.dir/__/videoio/ src/cap_vfw.cpp.obj [ 53%] Building CXX object modules/world/CMakeFiles/opencv_world.dir/__/videoio/ src/cap_ffmpeg.cpp.obj D:\Resource\opencv\sources\modules\videoio\src\cap_ffmpeg.cpp:65:42: warning: ty pe qualifiers ignored on function return type [-Wignored-qualifiers] static const HMODULE cv_GetCurrentModule() ^ [ 53%] Building CXX object modules/world/CMakeFiles/opencv_world.dir/__/highgui/ src/window.cpp.obj [ 53%] Building CXX object modules/world/CMakeFiles/opencv_world.dir/__/highgui/ src/window_w32.cpp.obj D:\Resource\opencv\sources\modules\highgui\src\window_w32.cpp:51:6: warning: "_W IN32_IE" is not defined [-Wundef] #if (_WIN32_IE < 0x0500) ^ D:\Resource\opencv\sources\modules\highgui\src\window_w32.cpp:52:99: note: #prag ma message: WARNING: Win32 UI needs to be compiled with _WIN32_IE >= 0x0500 (_WI N32_IE_IE50) #pragma message("WARNING: Win32 UI needs to be compiled with _WIN32_IE >= 0x050 0 (_WIN32_IE_IE50)") ^ D:\Resource\opencv\sources\modules\highgui\src\window_w32.cpp: In function ‘void cvSetModeWindow_W32(const char*, double)‘: D:\Resource\opencv\sources\modules\highgui\src\window_w32.cpp:474:47: error: ‘MO NITOR_DEFAULTTONEAREST‘ was not declared in this scope hMonitor = MonitorFromRect(&rect, MONITOR_DEFAULTTONEAREST); ^ D:\Resource\opencv\sources\modules\highgui\src\window_w32.cpp:474:71: error: ‘Mo nitorFromRect‘ was not declared in this scope hMonitor = MonitorFromRect(&rect, MONITOR_DEFAULTTONEAREST); ^ D:\Resource\opencv\sources\modules\highgui\src\window_w32.cpp: In function ‘LRES ULT MainWindowProc(HWND, UINT, WPARAM, LPARAM)‘: D:\Resource\opencv\sources\modules\highgui\src\window_w32.cpp:1377:45: error: ‘M ONITOR_DEFAULTTONEAREST‘ was not declared in this scope hMonitor = MonitorFromRect(&rect, MONITOR_DEFAULTTONEAREST); ^ D:\Resource\opencv\sources\modules\highgui\src\window_w32.cpp:1377:69: error: ‘M onitorFromRect‘ was not declared in this scope hMonitor = MonitorFromRect(&rect, MONITOR_DEFAULTTONEAREST); ^ D:\Resource\opencv\sources\modules\highgui\src\window_w32.cpp: In function ‘LRES ULT HighGUIProc(HWND, UINT, WPARAM, LPARAM)‘: D:\Resource\opencv\sources\modules\highgui\src\window_w32.cpp:1549:24: warning: left operand of comma operator has no effect [-Wunused-value] } while (0,0); // (0,0) instead of (0) to avoid MSVC compiler warni ng C4127: "conditional expression is constant" ^ modules\world\CMakeFiles\opencv_world.dir\build.make:4678: recipe for target ‘mo dules/world/CMakeFiles/opencv_world.dir/__/highgui/src/window_w32.cpp.obj‘ faile d mingw32-make[2]: *** [modules/world/CMakeFiles/opencv_world.dir/__/highgui/src/w indow_w32.cpp.obj] Error 1 CMakeFiles\Makefile2:2324: recipe for target ‘modules/world/CMakeFiles/opencv_wo rld.dir/all‘ failed mingw32-make[1]: *** [modules/world/CMakeFiles/opencv_world.dir/all] Error 2 Makefile:161: recipe for target ‘all‘ failed mingw32-make: *** [all] Error 2
在modules/highgui/src/precomp.hpp文件里面删除以下加粗加黑的内容
#if defined WIN32 || defined WINCE
#if !defined _WIN32_WINNT
#ifdef HAVE_MSMF
#define _WIN32_WINNT 0x0600 // Windows Vista
#else
#define _WIN32_WINNT 0x0500 // Windows 2000
#endif
#endif
#include <windows.h>
然后在modules/highgui/src/window_w32.cpp文件里面添加一下加粗加黑的内容
#if defined WIN32 || defined _WIN32 #define COMPILE_MULTIMON_STUBS // Required for multi-monitor support #ifndef _MULTIMON_USE_SECURE_CRT # define _MULTIMON_USE_SECURE_CRT 0 // some MinGW platforms have no strncpy_s #endif #if defined SM_CMONITORS && !defined MONITOR_DEFAULTTONEAREST # define MONITOR_DEFAULTTONULL 0x00000000 # define MONITOR_DEFAULTTOPRIMARY 0x00000001 # define MONITOR_DEFAULTTONEAREST 0x00000002 # define MONITORINFOF_PRIMARY 0x00000001 #endif #ifndef __inout # define __inout #endif #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" #endif #include <commctrl.h> #include <winuser.h> #include <stdlib.h> #include <string.h>
引用:http://blog.csdn.net/chentianqiao555/article/details/41154977
以上是关于opencv3.2.0 Cmake 3.8.0 编译问题的主要内容,如果未能解决你的问题,请参考以下文章
OpenCV3.2.0+opencv_contrib-3.2.0+VS2015+cmake
OpenCV3.3.0 + CLion + CMake 配置(Mac巨细无敌版)
win10 下的opencv3.2.0实现tracker常见问题----必要条件整理
Ubuntu 18.04下Cmake指定OpenCV版本编译(针对问题:fatal error: opencv2/xfeatures2d.hpp: No such file or directory)