Cinder + Kinectv2 via KCB2 compile error

I want to get started with Cinder and my Kinect for Windows v2.
Compiling my own project or any sample projects provided by Cinder-KCB2 results in this compilation error:

1>D:\Developer\Libraries\Cinder-0.9.3\blocks\Cinder-KCB2\src\Kinect2.cpp(1167,38): error C2280: 'Kinect2::Device::Process &Kinect2::Device::Process::operator =(const Kinect2::Device::Process &)': attempting to reference a deleted function
1>D:\Developer\Libraries\Cinder-0.9.3\blocks\Cinder-KCB2\src\Kinect2.h(416): message : compiler has generated 'Kinect2::Device::Process::operator =' here
1>D:\Developer\Libraries\Cinder-0.9.3\blocks\Cinder-KCB2\src\Kinect2.h(416,2): message : 'Kinect2::Device::Process &Kinect2::Device::Process::operator =(const Kinect2::Device::Process &)': function was implicitly deleted because a data member invokes a deleted or inaccessible function 'std::atomic<bool> &std::atomic<bool>::operator =(const std::atomic<bool> &)'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include\atomic(2166,13): message : 'std::atomic<bool> &std::atomic<bool>::operator =(const std::atomic<bool> &)': function was explicitly deleted

This library was updated 5 years ago, and it’s possible the recent VS versions are causing this error. I have not encountered this error before, and am unsure how to proceed.

Specs:

1 Like

You’re likely running into some variation of this. Try initializing the two std::atomic_bools properly inline in the header.

std::atomic_bool mNewData{false}; // or atomic_flag_init? Can't remember off the top of my head.
std::atomic_bool mRunning{false};

Since you’re using the kinect you’re pretty much guaranteed to be tethered to windows, and i’m not sure that it’s possible to get a torn read/write on a boolean on any version of windows, so you could probably get away with using regular bool (possibly volatile) instead of std::atomic_bool.

This is terrible advice and I absolutely wouldn’t use it in production but if you just want to get up and running so you can test the kinect it’s probably fine.

A

There’s an issue on github about this with a solution similar to @lithium’s suggestion.

1 Like

@gabor_papp I did not find that issue before but following that solution solved it, thanks!

1 Like