如何使用 OpenCV 解决 iOS 链接错误 [英] How to resolve iOS Link errors with OpenCV

查看:11
本文介绍了如何使用 OpenCV 解决 iOS 链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将最新版本的 openCV 添加到我的 iOS 项目中,但是当我编译时,我收到大约 30 个链接错误:

I'm trying to add the newest version of openCV to my iOS project, but when I compile, I get about 30 link errors:

例子:

Undefined symbols for architecture i386:
"cv::merge(std::vector<cv::Mat, std::allocator<cv::Mat> > const&, cv::_OutputArray const&)", referenced from:

我添加了 OpenCV 框架,以及所有其他必需的框架,在一个带有简单视频捕获的虚拟应用程序中(按照链接中的教程),它运行良好.

I added the OpenCV framework, along with all the other required frameworks, in a dummy app with a simple video capture (following the tutorial in the link), and it worked perfectly.

我不知道为什么它可以在一个地方运行得如此顺利,但在另一个地方却不行.我唯一的想法是我正在为两个应用程序之间的不同架构进行编译,但我认为我的目标是 armv7 和 armv7s.

I'm not sure why it could have worked so smoothly in one place, but not in the other. My only thought is that I ame compiling for different architectures between the two apps, but I think for both I'm aiming at armv7 and armv7s.

知道什么可能导致链接错误吗?

Any idea on what could be causing link errors?

推荐答案

检查一下:(假设你使用的是 LLVM 编译器)

Check this: (assuming you are using LLVM compiler)

目标 > 构建设置 > Apple LLVM 编译器 4.1 - 语言 > C++ 标准库
尝试选择

Target > Build Settings > Apple LLVM Compiler 4.1 - language > C++ Standard Library
try selecting

libstdc++ (GNU C++ standard library)`  

然后尝试切换到

libc++ (LLVM C++ standard library with C++11 support)

libstdc++ 似乎适用于较旧的 openCV 版本,libc++ 适用于较新的版本.如果您设置错误(无论哪种方式),您都会看到这些类型的错误.

libstdc++ seems to work for older builds of openCV, libc++ correct for newer builds. If you have it set wrong (either way) you will see these kinds of errors.

如果这不是原因,请在每个项目中并排打开构建设置并检查 每个 设置...

If that isn't the cause, open the build setting side by side in each project and check every setting...

我最近一直在努力解决这个问题 - 请参阅我的问题 这里,回答 这里和github示例这里.github项目包括几天前从当前源编译的opencv框架.现在,如果在 10.6/XCode4.2 或 10.7/XCode4.4+ 下编译,我正在整理一个多目标示例,该示例链接到不同版本的框架.[在github上这里]

I have been battling through this recently - see my question here, answers here and github sample here. The github project includes opencv framework compiled from current source a few days ago. Right now I am putting together a multi-target sample that links to a different version of the framework if compiling under 10.6/XCode4.2 or 10.7/XCode4.4+. [On github here]

更新

根据@mikewoz 的要求,您可能需要使用 libstdc++ 运行当前的 openCV 以保持与其他框架的兼容性.可以制作具有 libstdc++ 兼容性的当前版本.有关详细信息,请参阅我对 Mike 问题的回答:

As @mikewoz requested, you may need to run current openCV with libstdc++ to remain compatible with other frameworks. It is possible to make a current build with libstdc++ compatibility. For details see my answer to Mike's question here:

OpenCV 2.4.3+ with libstdc++ for iOS?

这篇关于如何使用 OpenCV 解决 iOS 链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆