ios openCV遇到的一些坑

ios openCV遇到的一些坑
这两天需要用openCV做一些东西,第一次接触这个东西,然而再导入到项目的时候报错不断,将我遇到的错误解决方法分享出来,以免更多的人在这里浪费时间:
(1)将加入openCV代码的.m文件改成.mm文件,然后要加上libc++.dylib到other link编译选项中,否则会出现很多错误
(2)若是直接将下载的openCV2.framework导入项目,里面有以前的版本,将会看不到那些文件,只留下A文件下的东西就好了。
(3)出现错误:
_**Undefined symbols for architecture armv7s:
“_jpeg_free_small”, referenced from:
_free_pool in opencv2(jmemmgr.o)
_self_destruct in opencv2(jmemmgr.o)
“_jpeg_mem_available”, referenced from:
_realize_virt_arrays in opencv2(jmemmgr.o)
“_jpeg_free_large”, referenced from:
_free_pool in opencv2(jmemmgr.o)
“_jpeg_open_backing_store”, referenced from:
_realize_virt_arrays in opencv2(jmemmgr.o)
“_jpeg_get_large”, referenced from:
_alloc_large in opencv2(jmemmgr.o)
_realize_virt_arrays in opencv2(jmemmgr.o)
“_jpeg_mem_term”, referenced from:
_jinit_memory_mgr in opencv2(jmemmgr.o)
_self_destruct in opencv2(jmemmgr.o)
“_jpeg_mem_init”, referenced from:
_jinit_memory_mgr in opencv2(jmemmgr.o)
“_jpeg_get_small”, referenced from:
_jinit_memory_mgr in opencv2(jmemmgr.o)
_alloc_small in opencv2(jmemmgr.o)
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)**
解决:1. Go to : [[http://sourceforge.net/projects/libjpeg-turbo/files/1.4.0/]] and download the libjpeg-turbo-1.4.0.dmg (3.8 MB) file.
2. Install the package. Once its done you will find the installed files under this path : /opt/libjpeg-turbo/lib
3. Open up your terminal and type the following command : lipo -info /opt/libjpeg-turbo/lib/libjpeg.a
4. If the terminal shows the following the output after running the command then it means, you can use the library for your iOS project(armv7/armv7s) * Architectures in the fat file: /opt/libjpeg-turbo/lib/libturbojpeg.a are: i386 x86_64 armv6 armv7 armv7s arm64*
5. Use finder to navigate to : /opt/libjpeg-turbo/lib and copy libjpeg.a and place it in your project folder.
6. Head over to your XCode project -> Click on Project Name -> Targets -> General -> Linked frameworks and libraries -> Click on the add button placed at the bottom -> include the libjpeg.a file
7. Compile the project. It shouldn’t show any more linker errors.
按照上述步骤应该可以解决。
(4)接着编译之后又遇到让人头疼的事情,说是’list’ file not found
看到c++的那一串东西,直接迷茫,结果网上找到了解决方法,
给外层加上#ifdef __cplusplus … #endif,我是这样就解决了,具体方法如下:
_**#ifndef OPENCV_BACKGROUND_SEGM_HPP
define OPENCV_BACKGROUND_SEGM_HPP
ifdef __cplusplus
include “opencv2/core/core.hpp”
include
namespace cv
{

}
endif
endif**
还有网上有提到这样解决方法:进入“Build Settings”,修改“Apple LLVM compiler 4.2 - Language”中“Comlile Sources As”的值为“Objective-C++”

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值