Categories
Development

opencv throws errors when building cap_avfoundation_mac

Compiling opencv on MacOS Mojave; everything was going well until make threw an error at cap_avfoundation_mac. Make complained about error: stray '@' in program and then went on to throw a bunch of errors on files included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks.

The errors go on for absolutely forever; however, most of them seem to be the same. Here are the most common ones:

error: 'nullable' does not name a type; did you mean 'cg_nullable'?   (x1,097)

error: misplaced '@property' Objective-C++ construct   (x77)

error: expected ')' before (either a ',', '*', or '>') token   (x983)

error: cannot find protocol declaration for (some Type)   (x552)

CMake command was

cmake -D CMAKE_BUILD_TYPE=RELEASE \
      -D CMAKE_INSTALL_PREFIX=/usr/local \
      -D OPENCV_EXTRA_MODULES_PATH=~/cpp/cv/opencv_contrib/modules \
      -D PYTHON3_LIBRARY=/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin/libpython3.7.dylib \
      -D PYTHON3_INCLUDE_DIR=/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/include/python3.7m \
      -D PYTHON3_EXECUTABLE=/usr/local/bin/python3 \
      -D BUILD_opencv_python2=OFF \
      -D BUILD_opencv_python3=ON \
      -D INSTALL_PYTHON_EXAMPLES=ON \
      -D INSTALL_C_EXAMPLES=OFF \
      -D OPENCV_ENABLE_NONFREE=ON \
      -D BUILD_EXAMPLES=ON \
      -D OPENCV_GENERATE_PKGCONFIG=ON \
      -D CMAKE_CXX_COMPILER=/usr/local/bin/g++-9 ..

Any idea what this is about? Help would be greatly appreciated.

EDIT: Here’s the start of the error messages.

[ 45%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_avfoundation_mac.mm.o
/Users/<user>/cpp/cv/opencv/modules/videoio/src/cap_avfoundation_mac.mm:360:13: error: stray '@' in program
  360 |             @{
      |             ^
/Users/<user>/cpp/cv/opencv/modules/videoio/src/cap_avfoundation_mac.mm:361:46: error: stray '@' in program
  361 |                 (id)kCVPixelBufferWidthKey:  @(1.0*width),
      |                                              ^
/Users/<user>/cpp/cv/opencv/modules/videoio/src/cap_avfoundation_mac.mm:362:46: error: stray '@' in program
  362 |                 (id)kCVPixelBufferHeightKey: @(1.0*height),
      |                                              ^
/Users/<user>/cpp/cv/opencv/modules/videoio/src/cap_avfoundation_mac.mm:363:55: error: stray '@' in program
  363 |                 (id)kCVPixelBufferPixelFormatTypeKey: @(pixelFormat)
      |                                                       ^
/Users/<user>/cpp/cv/opencv/modules/videoio/src/cap_avfoundation_mac.mm:367:13: error: stray '@' in program
  367 |             @{
      |             ^
/Users/<user>/cpp/cv/opencv/modules/videoio/src/cap_avfoundation_mac.mm:368:55: error: stray '@' in program
  368 |                 (id)kCVPixelBufferPixelFormatTypeKey: @(pixelFormat)
      |                                                       ^
/Users/<user>/cpp/cv/opencv/modules/videoio/src/cap_avfoundation_mac.mm:394:59: error: stray '@' in program
  394 |         pixelBufferOptions[(id)kCVPixelBufferWidthKey]  = @(1.0*width);
      |                                                           ^
/Users/<user>/cpp/cv/opencv/modules/videoio/src/cap_avfoundation_mac.mm:395:59: error: stray '@' in program
  395 |         pixelBufferOptions[(id)kCVPixelBufferHeightKey] = @(1.0*height);
      |                                                           ^
/Users/<user>/cpp/cv/opencv/modules/videoio/src/cap_avfoundation_mac.mm:694:61: error: stray '@' in program
  694 |     mAsset = [[AVAsset assetWithURL:[NSURL fileURLWithPath: @(filename)]] retain];
      |                                                             ^
/Users/<user>/cpp/cv/opencv/modules/videoio/src/cap_avfoundation_mac.mm:777:9: error: stray '@' in program
  777 |         @{
      |         ^
/Users/<user>/cpp/cv/opencv/modules/videoio/src/cap_avfoundation_mac.mm:778:51: error: stray '@' in program
  778 |             (id)kCVPixelBufferPixelFormatTypeKey: @(pixelFormat

Leave a Reply

Your email address will not be published. Required fields are marked *