构建 OpenCV (cap_avfoundation_mac) 时的编译错误

问题描述 投票:0回答:0

macOS v10.14 (Mojave) 上编译 OpenCV;一切都很顺利,直到 make

cap_avfoundation_mac
处抛出一个错误。 Make 抱怨
error: stray '@' in program
然后继续在 /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks.

包含的文件上抛出一堆错误

错误永远持续下去;但是,它们中的大多数似乎是相同的。以下是最常见的:

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 命令是

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 ..

这是关于什么的?

这是错误消息的开始。

[ 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
c++ opencv makefile cmake compiler-errors
© www.soinside.com 2019 - 2024. All rights reserved.