【问题标题】:OpenCV building fails due to DirectX由于 DirectX,OpenCV 构建失败
【发布时间】:2019-09-24 22:17:55
【问题描述】:

我正在关注guide 在 Windows 7 下为 Qt5 编译 OpenCV。 我正在使用:

  • CMake 3.14.3
  • OpenCV 4.1.0
  • Qt 5.12.2

我按照描述配置和设置参数。然后开始编译。它失败了很多类似的错误:

C:\opencv\sources\modules\core\src\directx.cpp:1055:5: error: 'cl_context' was not declared in this scope
     cl_context context = (cl_context)ctx.ptr();
     ^~~~~~~~~~
C:\opencv\sources\modules\core\src\directx.cpp:1055:5: note: suggested alternative: '_onexit'
     cl_context context = (cl_context)ctx.ptr();
     ^~~~~~~~~~
     _onexit
C:\opencv\sources\modules\core\src\directx.cpp:1057:5: error: 'cl_int' was not declared in this scope
     cl_int status = 0;
     ^~~~~~
C:\opencv\sources\modules\core\src\directx.cpp:1057:5: note: suggested alternative: 'lrint'
     cl_int status = 0;
     ^~~~~~
     lrint
C:\opencv\sources\modules\core\src\directx.cpp:1058:12: error: expected ';' before 'clImage'
     cl_mem clImage = 0;
            ^~~~~~~
C:\opencv\sources\modules\core\src\directx.cpp:1062:5: error: 'clImage' was not declared in this scope
     clImage = clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
     ^~~~~~~
C:\opencv\sources\modules\core\src\directx.cpp:1062:5: note: suggested alternative: 'IplImage'
     clImage = clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
     ^~~~~~~
     IplImage
C:\opencv\sources\modules\core\src\directx.cpp:1062:44: error: 'context' was not declared in this scope
     clImage = clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
                                            ^~~~~~~
C:\opencv\sources\modules\core\src\directx.cpp:1062:44: note: suggested alternative: 'onexit'
     clImage = clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
                                            ^~~~~~~
                                            onexit
C:\opencv\sources\modules\core\src\directx.cpp:1062:53: error: 'CL_MEM_WRITE_ONLY' was not declared in this scope
     clImage = clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);

我在 CMake 中禁用了 WITH_DIRECTX 标志,然后:

  1. 配置
  2. 生成
  3. mingw32-make clean
  4. mingw32-make -j 8

但错误仍然存​​在。 我还必须做些什么来解决这个问题?

【问题讨论】:

    标签: c++ windows opencv mingw directx


    【解决方案1】:

    要禁用 directx,我还必须关闭所有与 OpenCL 相关的项目:

    • OPENCL_FOUND
    • OPENCV_DNN_OPENCL
    • WITH_OPENCL
    • WITH_OPENCLAMDBLAS
    • WITH_OPENCLAMDFFT
    • 带有 OPENCL_D3D11_NV
    • WITH_OPENCL_SVM

    OpenCL 与 DirectX 相关并不是那么容易理解。

    【讨论】:

      猜你喜欢
      • 2014-05-23
      • 2012-08-21
      • 2020-12-22
      • 1970-01-01
      • 1970-01-01
      • 2022-12-29
      • 2020-01-16
      • 2018-05-08
      • 2018-01-12
      相关资源
      最近更新 更多