【问题标题】:Compiling latest OpenCV from source on OS X (with Cmake)在 OS X 上从源代码编译最新的 OpenCV(使用 Cmake)
【发布时间】:2011-09-25 07:27:50
【问题描述】:

我的问题:

我正在使用 cmake 从 Mac OS X 上的 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"

我是怎么到这里的:

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

这带有一个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

【问题讨论】:

  • 似乎找不到该文件:/Users/Matt/OpenCV/build/tmp/lib/Release/libopencv_highgui.a.
  • 最可能的原因是什么?
  • 你是怎么走到这一步的?您是否按照section 2 of the wiki 中的说明进行操作?

标签: macos opencv cmake


【解决方案1】:

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

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

为在 SO 上找到此内容的任何其他人编辑。原创文章、预建的OpenCV框架和构建脚本可以在我公司的website找到。预构建的框架现在是针对 OpenCV svn 修订版 7017 构建的。

【讨论】:

  • 是的 - 我在 Snow Leopard 10.6.8 上。我正在使用 XCode 3.2.5 和 iOS SDK 4.2。我最好的选择是什么?我现在没有足够的驱动器空间升级到 Lion。
  • 所以你确实安装了 iOS SDK。您可以尝试更新到最新的 iOS SDK (4.3) - 4.2 已经很老了。否则,我不确定为什么它不适合你。您也可以尝试从 Apple 开发人员网站下载 AVCam 示例并尝试构建它 - 这将检查您的 iOS SDK 安装是否正常,并且您的 AVFramework 标头等是否以某种方式搞砸了。
  • 好的,我会试试的。顺便说一句,我对最新版本感兴趣的主要原因是拼接模块的最新发展。它非常强大。
猜你喜欢
  • 1970-01-01
  • 2016-08-22
  • 2011-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多