OpenCV 3 on Mac with Xcode 6.2

Introduction

OpenCV 演变到v3已经快一年了。对于各类软件新版本的尝试已经没有了兴趣(乐趣?)。直到现在想测试一下TextProposals,发现作者用了OpenCV 3.0才最终决定再尝试一下 — 希望变化不要太大。

Main Problems and Solutions

opencv_contrib

add the following to the cmake command to compile with contrib modules

  • -D CMAKE_INSTALL_PREFIX=/path/to/opencv-3.1.0/build/
Conflicts with OpenCV from MacPorts

Early error message goes with anywhere cv::Mat is used!!

  • /opt/local/include/opencv2/core/mat.hpp:67:8: Incomplete type ‘cv::Mat’ named in nested name specifier

Strange thing is, why the heck the errors ended with an older version of OpenCV (2.4.11) installed from MacPorts?

Simply deactivate the macports version temporarily, or permanently!

  • sudo port deactivate opencv
CMake

Loads errors popped up (201 errors to be precise) when trying to build opencv_videoio module

Some say it need to link to CoreMedia and VideoToolbox Framework.
The trouble is, I could not for the life of me now find how to link framework in Xcode….

Fortunately, it turned out that’s not the real reason anyway.

In $OpenCV3.1.0_Root/cmake/OpenCVFindLibsVideo.cmake, when checking ffmpeg, it is hard-coded to link to static library at the end. So, change .a extension to .dylib solve the errors. Five places in total!

Undefined symbols for architecture x86_64:
  "_CMBlockBufferCreateWithMemoryBlock", referenced from:
      _videotoolbox_common_end_frame in libavcodec.a(videotoolbox.o)
  "_CMSampleBufferCreate", referenced from:
      _videotoolbox_common_end_frame in libavcodec.a(videotoolbox.o)
  "_CMVideoFormatDescriptionCreate", referenced from:
      _av_videotoolbox_default_init2 in libavcodec.a(videotoolbox.o)
  "_ModPlug_GetCurrentOrder", referenced from:
      _modplug_read_packet in libavformat.a(libmodplug.o)
  "_ModPlug_GetCurrentPattern", referenced from:
      _modplug_read_packet in libavformat.a(libmodplug.o)
  "_ModPlug_GetCurrentRow", referenced from:
      _modplug_read_packet in libavformat.a(libmodplug.o)
  "_ModPlug_GetCurrentSpeed", referenced from:
      _modplug_read_packet in libavformat.a(libmodplug.o)
  "_ModPlug_GetCurrentTempo", referenced from:
      _modplug_read_packet in libavformat.a(libmodplug.o)
  "_ModPlug_GetLength", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_GetMessage", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_GetName", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_GetSettings", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_InstrumentName", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_Load", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_NumChannels", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_NumInstruments", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_NumPatterns", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_NumSamples", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_Read", referenced from:
      _modplug_read_packet in libavformat.a(libmodplug.o)
  "_ModPlug_SampleName", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_Seek", referenced from:
      _modplug_read_seek in libavformat.a(libmodplug.o)
  "_ModPlug_SetSettings", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_Unload", referenced from:
      _modplug_read_close in libavformat.a(libmodplug.o)
  "_SSLClose", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
      _tls_close in libavformat.a(tls_securetransport.o)
  "_SSLCopyPeerTrust", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SSLCreateContext", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SSLHandshake", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SSLRead", referenced from:
      _tls_read in libavformat.a(tls_securetransport.o)
  "_SSLSetCertificate", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SSLSetConnection", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SSLSetIOFuncs", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SSLSetPeerDomainName", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SSLSetSessionOption", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SSLWrite", referenced from:
      _tls_write in libavformat.a(tls_securetransport.o)
  "_SecIdentityCreate", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SecItemImport", referenced from:
      _import_pem in libavformat.a(tls_securetransport.o)
  "_SecTrustEvaluate", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SecTrustSetAnchorCertificates", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_VTDecompressionSessionCreate", referenced from:
      _av_videotoolbox_default_init2 in libavcodec.a(videotoolbox.o)
  "_VTDecompressionSessionDecodeFrame", referenced from:
      _videotoolbox_common_end_frame in libavcodec.a(videotoolbox.o)
  "_VTDecompressionSessionInvalidate", referenced from:
      _av_videotoolbox_default_free in libavcodec.a(videotoolbox.o)
  "_VTDecompressionSessionWaitForAsynchronousFrames", referenced from:
      _videotoolbox_common_end_frame in libavcodec.a(videotoolbox.o)
  "___gmpz_add_ui", referenced from:
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
  "___gmpz_clear", referenced from:
      _ff_dh_free in libavformat.a(rtmpdh.o)
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
      _dh_is_valid_public_key in libavformat.a(rtmpdh.o)
      _ff_dh_compute_shared_secret_key in libavformat.a(rtmpdh.o)
  "___gmpz_cmp", referenced from:
      _dh_is_valid_public_key in libavformat.a(rtmpdh.o)
  "___gmpz_cmp_ui", referenced from:
      _dh_is_valid_public_key in libavformat.a(rtmpdh.o)
  "___gmpz_export", referenced from:
      _ff_dh_write_public_key in libavformat.a(rtmpdh.o)
      _ff_dh_compute_shared_secret_key in libavformat.a(rtmpdh.o)
  "___gmpz_fdiv_r_2exp", referenced from:
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
  "___gmpz_import", referenced from:
      _ff_dh_compute_shared_secret_key in libavformat.a(rtmpdh.o)
  "___gmpz_init2", referenced from:
      _ff_dh_init in libavformat.a(rtmpdh.o)
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
      _dh_is_valid_public_key in libavformat.a(rtmpdh.o)
      _ff_dh_compute_shared_secret_key in libavformat.a(rtmpdh.o)
  "___gmpz_mul_2exp", referenced from:
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
  "___gmpz_powm", referenced from:
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
      _dh_is_valid_public_key in libavformat.a(rtmpdh.o)
      _ff_dh_compute_shared_secret_key in libavformat.a(rtmpdh.o)
  "___gmpz_set", referenced from:
      _dh_is_valid_public_key in libavformat.a(rtmpdh.o)
  "___gmpz_set_str", referenced from:
      _ff_dh_init in libavformat.a(rtmpdh.o)
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
      _ff_dh_compute_shared_secret_key in libavformat.a(rtmpdh.o)
  "___gmpz_set_ui", referenced from:
      _ff_dh_init in libavformat.a(rtmpdh.o)
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
      _dh_is_valid_public_key in libavformat.a(rtmpdh.o)
  "___gmpz_sizeinbase", referenced from:
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
      _ff_dh_write_public_key in libavformat.a(rtmpdh.o)
      _ff_dh_compute_shared_secret_key in libavformat.a(rtmpdh.o)
  "___gmpz_sub_ui", referenced from:
      _dh_is_valid_public_key in libavformat.a(rtmpdh.o)
  "_bd_close", referenced from:
      _bluray_close in libavformat.a(bluray.o)
  "_bd_free_title_info", referenced from:
      _bluray_open in libavformat.a(bluray.o)
  "_bd_get_disc_info", referenced from:
      _bluray_open in libavformat.a(bluray.o)
  "_bd_get_title_info", referenced from:
      _bluray_open in libavformat.a(bluray.o)
  "_bd_get_title_size", referenced from:
      _bluray_seek in libavformat.a(bluray.o)
  "_bd_get_titles", referenced from:
      _bluray_open in libavformat.a(bluray.o)
  "_bd_open", referenced from:
      _bluray_open in libavformat.a(bluray.o)
  "_bd_read", referenced from:
      _bluray_read in libavformat.a(bluray.o)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值