将Xcode升级到4.5.2并将OpenCV升级到2.4.3后出现链接器错误 [英] Linker errors after upgrading Xcode to 4.5.2 and OpenCV to 2.4.3

查看:230
本文介绍了将Xcode升级到4.5.2并将OpenCV升级到2.4.3后出现链接器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目工作正常,直到今天早上。我使用的是xcode 4.3,以及旧版本的OpenCV(我不确定确切的版本)。 OSX已经是10.7.x,但不是10.7.5



今天,将OSX升级到10.7.5,xcode升级到4.5.2,然后下载OpenCV 2.4.3 ,我在尝试构建项目时遇到以下链接器错误:

My project was working just fine until this morning. I was using xcode 4.3, and an older version of OpenCV (I'm not sure about the exact version). OSX was already 10.7.x, but not 10.7.5

Today, after upgrading OSX to 10.7.5, xcode to 4.5.2, and downloading OpenCV 2.4.3, I am getting the following linker errors when trying to build the project:


架构armv7的未定义符号:

_ OBJC_CLASS _ $ _ ALAssetsLibrary,引自:
opencv2中的objc-class-ref(cap_ios_video_camera.o)

cv :: FeatureDetector :: create (std :: string const&),引自:
- ImageAnalyzer.o中的[ImageAnalyzer detectBlobs:]

cv :: FeatureDetector :: detect(cv: :Mat const&,std :: vector>&,cv :: Mat const&)const,引自:
- ImageAnalyzer.o中的[ImageAnalyzer detectBlobs:]

ld:找不到架构armv7的符号

clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)

Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_ALAssetsLibrary", referenced from:
objc-class-ref in opencv2(cap_ios_video_camera.o)
"cv::FeatureDetector::create(std::string const&)", referenced from:
-[ImageAnalyzer detectBlobs:] in ImageAnalyzer.o
"cv::FeatureDetector::detect(cv::Mat const&, std::vector >&, cv::Mat const&) const", referenced from:
-[ImageAnalyzer detectBlobs:] in ImageAnalyzer.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

为了使用t他新的opencv框架我删除了对旧框架的引用,并将项目引用到从这里

我也删除了对 libz.dylib 的引用,并添加了改为引用 libc ++。dylib

最后一步是将前缀文件更新为新框架。前缀文件中的相关部分现在如下所示:

In order to use the new opencv framework I removed the reference to the old framework, and referenced the project to the official prebuilt opencv2.framework downloaded from here.
I also removed the reference to libz.dylib, and added a reference to libc++.dylib instead.
Last step was to update the prefix file to the new framework. The relevant part in the prefix file now looks like this:

#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif

这一切都缩小到这4个链接器错误我似乎无法摆脱。我尝试使用 libstdc ++。dylib ,但我遇到了更多错误。我也尝试过自己构建OpenCV,如这里,但我仍然遇到与预建框架相同的错误。



我错过了什么?我的项目还需要改变吗?





更新:

如图所示这里,将C ++标准库设置为libc ++(带有C ++ 11支持的LLVM C ++标准库)只有一个错误:

It all narrowed down to these 4 linker errors I can't seem to get rid of. I tried using libstdc++.dylib, but I am getting even more errors. I also tried building OpenCV myself as explained here, but I am still getting the same errors as the prebuilt framework.

What did I miss? Is there anything else I need to change in my project?


UPDATE:
As seen here, setting the "C++ Standard Library" to "libc++ (LLVM C++ standard libray with C++ 11 support" yielded only one error:


clang:错误:-stdlib = libc ++的无效部署目标(需要iOS 5.0或更高版本)

clang: error: invalid deployment target for -stdlib=libc++ (requires iOS 5.0 or later)

将部署目标更改为iOS 5终于让我的项目再次运行。

这是否意味着OpenCV 2.4 .3不适用于5岁以上的iOS版本?

Changing the deployment target to iOS 5 finally got my project to run again.
Does this mean OpenCV 2.4.3 doesn't work on iOS versions older than 5?

推荐答案

因为我似乎无法得到关于版本(既不在这里也不在OpenCV Q& A网站上),我将发布这个作为答案,因为它至少解决了这个问题。这是描述这里



在你的项目中 Build Settings ,请转到 Apple LLVM编译器4.1-Language 部分。

有:

设置 C ++语言方言编译器默认

C ++标准库设置为 libc ++(支持C ++ 11的LLVM C ++标准库)



执行上述操作后,我停止了获取这些链接器错误,而只收到一个错误,表示仅支持iOS 5及更高版本。在项目总结中将部署目标更改为5.0就行了。



最后一点,我还是不确定它是什么意味着,关于OpenCV 2.4.3与5岁以上iOS版本的兼容性。

Since I can't seem to get an answer regarding the versions (neither here nor at the OpenCV Q&A site), I'm going to post this as an answer, as it at least solved the issue. This is described here.

In your project's Build Settings, go down to the section Apple LLVM compiler 4.1-Language.
There:
Set C++ Language Dialect to Compiler Default
Set C++ Standard Libray to libc++ (LLVM C++ standard libray with C++ 11 support

After doing the above, I stopped getting those linker errors, and only got one error instead, which stated that only iOS 5 and above is supported. Changing the Deployment Target to 5.0 in the project summery did the trick.

On a final note, I'm still not sure what it means, regarding OpenCV 2.4.3's compatibility with iOS versions older than 5.

这篇关于将Xcode升级到4.5.2并将OpenCV升级到2.4.3后出现链接器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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