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

来源:互联网 发布:csgo和彩虹六号知乎 编辑:程序博客网 时间:2024/06/05 06:39


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 0