[英]Cocoapods OpenCV 2.4.10 Linker Error
I'm trying to build a simple project using OpenCV 2.4.10 but I get a bunch of errors like this: 我正在尝试使用OpenCV 2.4.10构建一个简单的项目,但是我得到了一堆这样的错误:
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)
Here is ViewController.m 这是ViewController.m
#import "ViewController.h"
#import <opencv2/opencv.hpp>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
cv::Mat greyMat;
}
Podfile Podfile
platform :ios, '8.1'
pod 'OpenCV', '2.4.10'
Project builds just fine when I use version 2.4.9.1 or 2.4.9. 当我使用2.4.9.1或2.4.9版时,Project构建得很好。
I was also able to build this project with framework file downloaded from URL which I found in podspec 2.4.10. 我还能够使用从podspec 2.4.10中找到的URL下载的框架文件构建此项目。
So here's a little workaround. 所以这里有一点解决方法。 The problem is because the XCode project is unable to link to the libjpeg.a library.
问题是因为XCode项目无法链接到libjpeg.a库。 So thats why you get the above errors when you compile the project.
这就是为什么在编译项目时出现上述错误的原因。
Follow these steps : 跟着这些步骤 :
I've added the new versions of OpenCV to CocoaPods (2.4.11, 2.4.12, 2.4.12.3, 3.0.0). 我已经将新版本的OpenCV添加到CocoaPods(2.4.11,2.4.12,2.4.12.3,3.0.0)。
2.4.11, 2.4.12, and 2.4.12.3 need libjpeg to be linked, so now the pod actually downloads the repo, compiles from source, and then links libjpeg in addition to the opencv2.framework file. 2.4.11,2.4.12和2.4.12.3需要链接libjpeg,所以现在pod实际上下载了repo,从源代码编译,然后除了opencv2.framework文件之外还链接libjpeg。 This works out of the box now through CocoaPods, however it takes a while when doing
pod install
since it's compiling from source. 现在通过CocoaPods开箱即用,但是在进行
pod install
时需要一段时间,因为它是从源代码编译的。 Just make sure not to cancel it while it's doing that (there's a bug in CocoaPods that causes issues if it's canceled). 只是确保在它执行时不取消它(CocoaPods中的一个错误会导致问题,如果它被取消)。
Under the hood, 3.0.0 works just like before with the prebuilt opencv2.framework file and can now be installed just fine through CocoaPods. 在引擎盖下,3.0.0与之前的opencv2.framework文件一样工作,现在可以通过CocoaPods安装得很好。
Version 2.4.10 is still broken in CocoaPods, but since that version throws errors while compiling from source on my machine, there's not much I can do. 版本2.4.10在CocoaPods中仍然被破坏,但由于该版本在我的机器上从源代码编译时会抛出错误,所以我无能为力。
(Note: I am not the original maintainer of the pod, I merely contributed these new versions.) (注意:我不是pod的原始维护者,我只贡献了这些新版本。)
The same issue I faced with open CV and found a useful link below that resolved my errors of my project : 我在开放式简历中面临同样的问题,并在下面找到了一个有用的链接,解决了我的项目错误:
http://blog.csdn.net/iOSLearner_Nana/article/details/45174365 http://blog.csdn.net/iOSLearner_Nana/article/details/45174365
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.