在此范围内未声明构建OpenCV :: MonitorFromRect时出错

 1397527971_3148ce 发布于 2023-02-03 10:10

我试图建立OpenCV version 2.4.8使用它CodeBlocksMinGw.我按照这里的说明进行操作.但是我得到了以下错误.我不知道如何解决它.我在网上搜索没有找到任何有用的东西.

这也没有解决.

我不想弄乱openCV代码,我打算OpenCV在我的项目中使用,这是我第一次使用它.

[ 26%] Built target pch_Generate_opencv_highgui
[ 26%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_w32.cpp.obj
C:\Program Files (x86)\opencv\sources\modules\highgui\src\window_w32.cpp: In function 'void cvSetModeWindow_W32(const char*, double)':
C:\Program Files (x86)\opencv\sources\modules\highgui\src\window_w32.cpp:477: error: 'MonitorFromRect' was not declared in this scope
C:\Program Files (x86)\opencv\sources\modules\highgui\src\window_w32.cpp: In function 'LRESULT MainWindowProc(HWND__*, UINT, WPARAM, LPARAM)':
C:\Program Files (x86)\opencv\sources\modules\highgui\src\window_w32.cpp:1355: error: 'MonitorFromRect' was not declared in this scope
mingw32-make.exe[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_w32.cpp.obj] Error 1
mingw32-make.exe[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
mingw32-make.exe: *** [all] Error 2 

我试图手动将该函数的原型包含在文件中,但后来又链接错误.
有谁请告诉我这里可能出了什么问题?我该如何解决?

1 个回答
  • 看来最近提交的所有更改都没有反映在您的结帐中.要解决问题,请进行以下更改:

    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>
    

    这将解决构建错误.

    2023-02-03 10:11 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有