Building error OpenCV

OpenCV+Astra Orbbec OpenNi SDK generate an error while building.

Do anyone knows a solution?

  • Windows 10,
  • Cmake 3.20.4
  • Qt 6.1.1 Mingw 8.1.0

helo, please replace the screenshot with a TXT version, thank you

do you have any mingw compatible libs in those sdk’s (*.a) ?

(from orbbec )

Supports development with both Visual Studio 2013 and Visual Studio 2015.

openNi2.lib only.

[ 19%] Linking CXX shared library …\bin\libopencv_videoio453.dll

CMakeFiles\opencv_videoio.dir/objects.a(cap_openni2.cpp.obj):cap_openni2.cpp:(.text$__tcf_0+0x3): undefined reference to `__imp_oniShutdown’

CMakeFiles\opencv_videoio.dir/objects.a(cap_openni2.cpp.obj):cap_openni2.cpp:(.text$_ZN6openni6OpenNI16waitForAnyStreamEPPNS_11VideoStreamEiPii.part.53.constprop.239+0x54): undefined reference to `__imp_oniWaitForAnyStream’

collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [modules\videoio\CMakeFiles\opencv_videoio.dir\build.make:297: bin/libopencv_videoio453.dll] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:8303: modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
mingw32-make: *** [Makefile:165: all] Error 2

that’s for vs, not mingw. the linker cannot find the oni symbols, wrong lib format

i’m afraid, if you dont find a onni sdk src and build that yourself, – you have to switch to vs to use the opennni sdk.

Thank you.
I asked Orbbeс for this error and waiting for reply.
This guy did this.
But I don’t understand how…
I tried to do the same, but receive an error.

you can compile opencv using mingw, no problem.
but you cannot use the openni sdk with mingw

I understand, but if you browse to the end of this page

you can see, that jmysu connect the camera Orbbec with SDK for VS to the application building with mingw.

QT5 app for Orbbec Astra depth/IR camera w/ OpenNI2+OpenCV4…

I don’t understand how he can do this.

As i can see, he change something in file OniPlatform.h to make compatibility with mingw.

Thank you. I’ll try to change to VS.

1 Like

that code does not try to link opencv’s videoio lib against openni, but instead
uses the openni library directly in main()

there also seems to be a (self-build ?) libopenni2.a here

maybe ask the author ?

Many thanks,
I built OpenCV with OpenNi support using include and lib Redistributable folders from Orbbec SDK.
Building ended without errors. Building parameters I took from issue

I added in my project only h file. #include <opencv2/openNI/OpenNI.h>
lib -lopenni2.dll not needed.

And now this simple code work Ok.
Device astra;

rc = OpenNI::initialize();
if (rc != STATUS_OK)
  cout << "Initialization failed!!  " << oniGetExtendedError() << endl;
  return 1;
rc =;
if (rc != STATUS_OK)
  cout << "Astra camera not found  " << oniGetExtendedError() << endl;
  return 2;
cout << "Astra found"  << endl;

If you know where I can find information about methods of transform frame grabbed by OpenNi to OpenCV Mat object, please inform me.

again, it is all in the sample code there