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

查看:133
本文介绍了如何使用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天全站免登陆