iOS OpenCV我安装遇到的问题和解决办法


1.直接通过Build phases -> Link binary with Libraries 添加opencv2.framework


2.可能出现如下错误:
 Undefined symbols for architecture x86_64:
 "_jpeg_free_large", referenced from:
 _free_pool in opencv2(jmemmgr.o)
 "_jpeg_free_small", referenced from:
 _free_pool in opencv2(jmemmgr.o)
 _self_destruct in opencv2(jmemmgr.o)
 "_jpeg_get_large", referenced from:
 _alloc_large in opencv2(jmemmgr.o)
 _alloc_barray in opencv2(jmemmgr.o)
 "_jpeg_get_small", referenced from:
 _jinit_memory_mgr in opencv2(jmemmgr.o)
 _alloc_small in opencv2(jmemmgr.o)
 "_jpeg_mem_available", referenced from:
 _realize_virt_arrays in opencv2(jmemmgr.o)
 "_jpeg_mem_init", referenced from:
 _jinit_memory_mgr in opencv2(jmemmgr.o)
 "_jpeg_mem_term", referenced from:
 _jinit_memory_mgr in opencv2(jmemmgr.o)
 _self_destruct in opencv2(jmemmgr.o)
 "_jpeg_open_backing_store", referenced from:
 _realize_virt_arrays in opencv2(jmemmgr.o)
 ld: symbol(s) not found for architecture x86_64
 clang: error: linker command failed with exit code 1 (use -v to see invocation)
 
 解决办法:
 安装:libjpeg-turbo.dmg : https://sourceforge.net/projects/libjpeg-turbo/files/1.4.0/
 在终端运行:lipo -info /opt/libjpeg-turbo/lib/libjpeg.a 将会出现以下内容:
 Architectures in the fat file: /opt/libjpeg-turbo/lib/libjpeg.a are: i386 x86_64 armv6 armv7 armv7s arm64
 然后将/opt/libjpeg-turbo/lib/libjpeg.a 加到你的工程里面
 

 

3.继续运行

 你的工程可能还会出现如下错误:
 Undefined symbols for architecture arm64:
 "_OBJC_CLASS_$_ALAssetsLibrary", referenced from:
 objc-class-ref in opencv2(cap_ios_video_camera.o)
 "_CMSampleBufferGetPresentationTimeStamp", referenced from:
 -[CvVideoCamera captureOutput:didOutputSampleBuffer:fromConnection:] in opencv2(cap_ios_video_camera.o)
 "_CMTimeMake", referenced from:
 -[CvVideoCamera createVideoDataOutput] in opencv2(cap_ios_video_camera.o)
 "_CMSampleBufferGetImageBuffer", referenced from:
 -[CaptureDelegate captureOutput:didOutputSampleBuffer:fromConnection:] in opencv2(cap_avfoundation.o)
 -[CvVideoCamera captureOutput:didOutputSampleBuffer:fromConnection:] in opencv2(cap_ios_video_camera.o)
 ld: symbol(s) not found for architecture arm64
 clang: error: linker command failed with exit code 1 (use -v to see invocation)
 
 解决办法:
 在你的工程添加3个iOS framework : CoreVideo.framework, AssetsLibrary.framework, CoreMedia.framework.
 

 

4.还可能出现如下错误

 dyld: Library not loaded: /opt/libjpeg-turbo/lib/libjpeg.62.dylib
 Referenced from: /Users/malata/Library/Developer/CoreSimulator/Devices/5A63F3E9-9097-46F6-879C-66C26135B5AA/data/Containers/Bundle/Application/33C4EED6-79E7-48A5-B798-E65FF127F640/LocationManager.app/LocationManager
 Reason: no suitable image found.  Did find:
/opt/libjpeg-turbo/lib/libjpeg.62.dylib: mach-o, but not built for iOS simulator
 
 解决办法很简单:
 将添加进入工程的libjpeg.a 在Build phases -> Link binary with Libraries 把required 改成 optional。
 

 

5.还可能出现如下错误

 在background_segm.hpp里出现“ 'list' file not found”
 解决办法很简单:
 1)把用到opencv的类的后缀从.m改为.mm
 2)导入libc++.dylib库
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

u014068781

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值