macos - 在 OS X 上从源代码编译最新的 OpenCV(使用 Cmake)

标签 macos opencv cmake

我的问题:

我在 Mac OS X 上使用 cmake 从 SVN 编译最新的 OpenCV,它在终端输出的末尾有一个错误。我对 Cmake 不够熟悉,无法真正找出问题所在。什么意思?

这是最后几行输出:

CMake Error at modules/highgui/cmake_install.cmake:38 (FILE):
  file INSTALL cannot find "/Users/Matt/OpenCV/build/tmp/lib/Release/libopencv_highgui.a".
Call Stack (most recent call first):
  modules/cmake_install.cmake:36 (INCLUDE)
  cmake_install.cmake:45 (INCLUDE)


make: *** [install_buildpart_0] Error 1
Command /bin/sh failed with exit code 2
Command /bin/sh failed with exit code 2
** BUILD FAILED **


The following build commands failed:
opencv_highgui:
    CompileC "/Users/Matt/OpenCV/build/tmp/modules/highgui/
        OpenCV.build/Release-iphonesimulator/opencv_highgui.build/
        Objects-normal/i386/cap_avfoundation.o" 
        "/Users/Matt/OpenCV/opencv/modules/highgui/src/cap_avfoundation.mm" 
        normal i386 objective-c++ com.apple.compilers.gcc.4_2
install:
    PhaseScriptExecution "CMake PostBuild Rules" "/Users/Matt/OpenCV/build/tmp/
        OpenCV.build/Release-iphonesimulator/install.build/
        Script-10907B010907B010907B0000.sh"

我是怎么到这里的:

我从 github 下载了 Aptogo OpenCV 框架 https://github.com/aptogo/OpenCVForiPhone

这带有一个 bash 脚本,用于使用 Cmake 编译 OpenCV,并将结果转换为 XCode 框架(我认为):

https://github.com/aptogo/OpenCVForiPhone/blob/master/opencvbuild.sh

我从 SVN 查看了最新的 OpenCV 源代码并在其上运行了这个脚本。

更多错误

在日志的前面找到对 cap_avfoundation.mm 的引用。

CompileC "/Users/Matt/OpenCV/build/tmp/modules/highgui/OpenCV.build/Release-iphonesimulator/opencv_highgui.build/Objects-normal/i386/cap_avfoundation.o" modules/highgui/src/cap_avfoundation.mm normal i386 objective-c++ com.apple.compilers.gcc.4_2
    cd "/Users/Matt/OpenCV/opencv"
    setenv LANG en_US.US-ASCII
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/mattmontag/Unix/pvc/UTILITIES:/Users/mattmontag/Unix/pvc/bin"
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -x objective-c++ -arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O3 -DCMAKE_INTDIR="Release" -DHAVE_ALLOCA -DHAVE_ALLOCA_H -DHAVE_LIBPTHREAD -DHAVE_UNISTD_H -DHAVE_CVCONFIG_H -DHAVE_IMAGEIO=1 -DHAVE_COCOA=1 -DHAVE_AVFOUNDATION=1 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk -fexceptions -mmacosx-version-min=10.6 -fobjc-abi-version=2 -fobjc-legacy-dispatch -D__IPHONE_OS_VERSION_MIN_REQUIRED=40200 -Wmost -Wno-four-char-constants -Wno-unknown-pragmas "-F/Users/Matt/OpenCV/build/tmp/lib/Release" "-I/Users/Matt/OpenCV/build/tmp/lib/Release/include" "-I/Users/Matt/OpenCV/opencv" "-I/Users/Matt/OpenCV/build/tmp" "-I/Users/Matt/OpenCV/opencv/include" "-I/Users/Matt/OpenCV/opencv/include/opencv" "-I/Users/Matt/OpenCV/opencv/modules/highgui/include" "-I/Users/Matt/OpenCV/opencv/modules/highgui/../core/include" "-I/Users/Matt/OpenCV/opencv/modules/highgui/../imgproc/include" "-I/Users/Matt/OpenCV/opencv/modules/highgui/src" "-I/Users/Matt/OpenCV/build/tmp/modules/highgui" "-I/Users/Matt/OpenCV/build/tmp/modules/highgui/OpenCV.build/Release-iphonesimulator/opencv_highgui.build/DerivedSources/i386" "-I/Users/Matt/OpenCV/build/tmp/modules/highgui/OpenCV.build/Release-iphonesimulator/opencv_highgui.build/DerivedSources" -c "cap_avfoundation.mm" -o "/Users/Matt/OpenCV/build/tmp/modules/highgui/OpenCV.build/Release-iphonesimulator/opencv_highgui.build/Objects-normal/i386/cap_avfoundation.o"

cap_avfoundation.mm:59: error: cannot find protocol declaration for 'AVCaptureVideoDataOutputSampleBufferDelegate'
cap_avfoundation.mm:71: error: expected type-specifier before 'AVCaptureOutput'
cap_avfoundation.mm:71: error: expected `)' before 'AVCaptureOutput'
cap_avfoundation.mm:71: error: expected `;' before '*' token
cap_avfoundation.mm:101: error: ISO C++ forbids declaration of 'AVCaptureSession' with no type
cap_avfoundation.mm:101: error: expected ';' before '*' token
cap_avfoundation.mm:102: error: ISO C++ forbids declaration of 'AVCaptureDeviceInput' with no type
cap_avfoundation.mm:102: error: expected ';' before '*' token
cap_avfoundation.mm:103: error: ISO C++ forbids declaration of 'AVCaptureVideoDataOutput' with no type
cap_avfoundation.mm:103: error: expected ';' before '*' token
cap_avfoundation.mm:104: error: ISO C++ forbids declaration of 'AVCaptureDevice' with no type
cap_avfoundation.mm:104: error: expected ';' before '*' token
cap_avfoundation.mm: In constructor 'CvCaptureCAM::CvCaptureCAM(int)':
cap_avfoundation.mm:236: error: 'mCaptureSession' was not declared in this scope
cap_avfoundation.mm:237: error: 'mCaptureDeviceInput' was not declared in this scope
cap_avfoundation.mm:238: error: 'mCaptureDecompressedVideoOutput' was not declared in this scope
cap_avfoundation.mm: In member function 'void CvCaptureCAM::stopCaptureDevice()':
cap_avfoundation.mm:308: error: 'mCaptureSession' was not declared in this scope
cap_avfoundation.mm:311: error: 'mCaptureDeviceInput' was not declared in this scope
cap_avfoundation.mm:313: error: 'mCaptureDecompressedVideoOutput' was not declared in this scope
cap_avfoundation.mm: In member function 'int CvCaptureCAM::startCaptureDevice(int)':
cap_avfoundation.mm:324: error: 'AVCaptureDevice' was not declared in this scope
cap_avfoundation.mm:324: error: 'device' was not declared in this scope
cap_avfoundation.mm:341: error: 'mCaptureDevice' was not declared in this scope
cap_avfoundation.mm:347: error: 'mCaptureDeviceInput' was not declared in this scope
cap_avfoundation.mm:347: error: 'AVCaptureDeviceInput' was not declared in this scope
cap_avfoundation.mm:348: error: 'mCaptureSession' was not declared in this scope
cap_avfoundation.mm:348: error: 'AVCaptureSession' was not declared in this scope
cap_avfoundation.mm:360: error: 'mCaptureDecompressedVideoOutput' was not declared in this scope
cap_avfoundation.mm:360: error: 'AVCaptureVideoDataOutput' was not declared in this scope
cap_avfoundation.mm:390: error: 'AVCaptureSessionPresetMedium' was not declared in this scope
cap_avfoundation.mm: In member function 'void CvCaptureCAM::setWidthHeight()':
cap_avfoundation.mm:427: error: 'mCaptureDecompressedVideoOutput' was not declared in this scope
cap_avfoundation.mm: In member function 'virtual double CvCaptureCAM::getProperty(int)':
cap_avfoundation.mm:490: error: 'mCaptureDeviceInput' was not declared in this scope
cap_avfoundation.mm:491: warning: no '-formatDescription' method found
cap_avfoundation.mm:491: warning: (Messages without a matching method signature
cap_avfoundation.mm:491: warning: will be assumed to return 'id' and accept
cap_avfoundation.mm:491: warning: '...' as arguments.)
cap_avfoundation.mm:491: error: cannot convert 'objc_object*' to 'const opaqueCMFormatDescription*' in initialization
cap_avfoundation.mm:505: error: 'mCaptureDevice' was not declared in this scope
cap_avfoundation.mm: In member function 'virtual bool CvCaptureCAM::setProperty(int, double)':
cap_avfoundation.mm:545: error: 'mCaptureDevice' was not declared in this scope
cap_avfoundation.mm:558: error: 'mCaptureDevice' was not declared in this scope
cap_avfoundation.mm:571: error: 'mCaptureDevice' was not declared in this scope
cap_avfoundation.mm:584: error: 'mCaptureDevice' was not declared in this scope
cap_avfoundation.mm:597: error: 'mCaptureDevice' was not declared in this scope
cap_avfoundation.mm: At global scope:
cap_avfoundation.mm:657: error: expected type-specifier before 'AVCaptureOutput'
cap_avfoundation.mm:657: error: expected `)' before 'AVCaptureOutput'
cap_avfoundation.mm: In function 'void -[CaptureDelegate captureOutput:](CaptureDelegate*, objc_selector*, <type error>)':
cap_avfoundation.mm:657: error: expected `{' before '*' token
cap_avfoundation.mm:657: error: expected unqualified-id before ')' token
cap_avfoundation.mm:657: error: expected constructor, destructor, or type conversion before ')' token
cap_avfoundation.mm:1324: error: expected `@end' at end of input
cap_avfoundation.mm:1324: warning: incomplete implementation of class 'CaptureDelegate'
cap_avfoundation.mm:1324: warning: method definition for '-getOutput' not found
cap_avfoundation.mm:1324: warning: method definition for '-updateImage' not found

最佳答案

这里是来自 Aptogo 的 Robin - 我编写了您正在谈论的构建脚本。我刚刚尝试使用最新的 OpenCV 主干(svn 修订版 6769)运行它并成功完成。我正在使用 CMake 版本 2.8.5。您知道该脚本旨在为 iOS 开发而非 OS X 开发构建框架,不是吗?如果您没有安装 iOS SDK,您可能会遇到问题。

导致构建失败的错误可能是“找不到‘AVCaptureVideoDataOutputSampleBufferDelegate’的协议(protocol)声明”。此协议(protocol)在 iOS 4 和 Mac OS 10.7 (Lion) 中可用。我猜您正在尝试在没有安装 iOS SDK 的情况下在 Snow Leopard 上进行构建。

编辑任何在 SO 上找到它的人。原文、预建的OpenCV框架和构建脚本可以在我公司的website上找到。 .预构建框架现在是针对 OpenCV svn 修订版 7017 构建的。

关于macos - 在 OS X 上从源代码编译最新的 OpenCV(使用 Cmake),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7544219/

相关文章:

java - 使用 quaqua LAF 在 Swing Mac OSX 应用程序上获取未保存的点

objective-c - 在沙箱中模拟按键

linux - 批量重命名 URL 编码的文件名和文件夹路径

python - Flask OpenCV 以字节为单位发送和接收图像

CLion 出现 CMAKE 错误

macos - Swift IBOutlets 在 awakeFromNib 中为零(xcode 6.1.1 osx 10.10.1)

python-3.x - 使用 plt.plot 与 plt.hist 的彩色图像直方图差异 [Python]

Python导入错误Opencv NameError : name highgui is not defined

带有符号链接(symbolic link)的 CMake 文件(安装文件 DESTINATION 目录)

visual-c++ - 删除 cmake 上的默认标志