CinderOpenCV build failed

I’m on MacOS, I created a new project using TinderBox, added the OpenCV library, and tried to build, but got 10 errors from the CinderOpenCV.h file.

Unknown type name 'Vec2f'; did you mean 'cv::Vec2f'?
Use of undeclared identifier 'Vec2f'
Unknown type name 'Vec2f'; did you mean 'cv::Vec2f'?
No member named 'y' in 'Vec<float, 2>'

And a number of others. I have OpenCV built and installed on my system, and I’ve check all the linker flags I’m not sure what the issue is. Seems like a namespace issue, but this is the library from github, I assume it would be working out of the box.

Use the dev branch of Cinder-OpenCV:

Or you can try Cinder-OpenCV3:

-Gabor

Using OpenCV3 seems to work, had to update linker settings, but once I did that it built without issue.

For anyone else who might be running into this issue, this was my fix:

  1. Download Cinder-OpenCV3 as a .zip

  2. Unzip

  3. Copy /includes and /lib directories into PROJECT_DIR/blocks/OpenCV and replace any existing contents.

  4. Update linker settings in XCode to reflect new files in /OpenCV/lib

  5. Build

Edit

I’m having an issue now when trying to actually use the library:

Undefined symbols for architecture x86_64:
"_clReleaseContext", referenced from:
   cv::ocl::Context::Impl::~Impl() in libopencv_core.a(ocl.cpp.o)

You only need step 4. because you put the block in a different folder than expected. The name of the block is Cinder-OpenCV3, if it is called like that you don’t have to change the linker settings.

I just cloned Cinder-OpenCV3 and built some samples in XCode. I did not see the problem you are having.

The sample project files have the old cinder library location, so you have to change the path of libcinder.a in Other linked flags:
Other linker flags/Debug
"$(CINDER_PATH)/lib/macosx/Debug/libcinder.a"
Other linker flags/Release
"$(CINDER_PATH)/lib/macosx/Release/libcinder.a"

I suggest that you should build the samples and check if they work.

If you’re using Cinder 9, Vec2f has been swapped out in favor of glm vec2. Check out the docs.