Mark
Mark

Reputation: 5102

OpenCV building fails due to DirectX

I'm following this guide to compile OpenCV for Qt5 under Windows 7. I'm using:

I configured and set the parameters as described. Then started the compilation. It fails with a lot of similar errors:

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);

I disabled the WITH_DIRECTX flag in CMake, then:

  1. Configure
  2. Generate
  3. mingw32-make clean
  4. mingw32-make -j 8

But the errors are still there. What else I must do to fix this issue?

Upvotes: 1

Views: 368

Answers (1)

Mark
Mark

Reputation: 5102

To disable directx I had to turn off also all the items related to OpenCL:

  • OPENCL_FOUND
  • OPENCV_DNN_OPENCL
  • WITH_OPENCL
  • WITH_OPENCLAMDBLAS
  • WITH_OPENCLAMDFFT
  • WITH OPENCL_D3D11_NV
  • WITH_OPENCL_SVM

It was not so straightforward to understand that OpenCL is related to DirectX.

Upvotes: 2

Related Questions