xcode Cocoapods OpenCV 2.4.10 链接器错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28331397/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cocoapods OpenCV 2.4.10 Linker Error
提问by foobarbaz
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
播客文件
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.
I was also able to build this project with framework file downloaded from URL which I found in podspec 2.4.10.
当我使用版本 2.4.9.1 或 2.4.9 时,项目构建得很好。
我还能够使用从 podspec 2.4.10 中找到的 URL 下载的框架文件来构建这个项目。
采纳答案by Kyle Fleming
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. This works out of the box now through CocoaPods, however it takes a while when doing pod install
since it's compiling from source. Just make sure not to cancel it while it's doing that (there's a bugin CocoaPods that causes issues if it's canceled).
2.4.11、2.4.12和2.4.12.3需要链接libjpeg,所以现在pod实际上是下载repo,从源代码编译,然后除了opencv2.framework文件之外还要链接libjpeg。这现在通过 CocoaPods 开箱即用,但是pod install
由于它是从源代码编译的,因此需要一段时间。只要确保在执行此操作时不要取消它(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.
CocoaPods 中的 2.4.10 版本仍然存在问题,但是由于该版本在我的机器上从源代码编译时会引发错误,因此我无能为力。
(Note: I am not the original maintainer of the pod, I merely contributed these new versions.)
(注意:我不是 pod 的原始维护者,我只是贡献了这些新版本。)
回答by Xeieshan
回答by Varun Ram
So here's a little workaround. The problem is because the XCode project is unable to link to the libjpeg.a library. So thats why you get the above errors when you compile the project.
所以这里有一些解决方法。问题是因为 XCode 项目无法链接到 libjpeg.a 库。这就是为什么在编译项目时会出现上述错误的原因。
Follow these steps :
按着这些次序 :
- 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.
- Install the package. Once its done you will find the installed files under this path : /opt/libjpeg-turbo/lib
- Open up your terminal and type the following command : lipo -info /opt/libjpeg-turbo/lib/libjpeg.a
- 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*
- Use finder to navigate to : /opt/libjpeg-turbo/lib and copy libjpeg.a and place it in your project folder.
- 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
- Compile the project. It shouldn't show any more libjpeg linker errors.
- 转到:[[ http://sourceforge.net/projects/libjpeg-turbo/files/1.4.0/]]并下载 libjpeg-turbo-1.4.0.dmg (3.8 MB) 文件。
- 安装软件包。完成后,您将在此路径下找到已安装的文件:/opt/libjpeg-turbo/lib
- 打开终端并输入以下命令:lipo -info /opt/libjpeg-turbo/lib/libjpeg.a
- 如果终端在运行命令后显示以下输出,则表示您可以将库用于您的 iOS 项目(armv7/armv7s)
- 胖文件中的架构:/opt/libjpeg-turbo/lib/libturbojpeg.a 是: i386 x86_64 armv6 armv7 armv7s arm64*
- 使用 finder 导航到:/opt/libjpeg-turbo/lib 并复制 libjpeg.a 并将其放在您的项目文件夹中。
- 转到您的 XCode 项目 -> 单击项目名称 -> 目标 -> 常规 -> 链接的框架和库 -> 单击位于底部的添加按钮 -> 包含 libjpeg.a 文件
- 编译项目。它不应再显示任何 libjpeg 链接器错误。
回答by paperpusher
回答by souvickcse
回答by Dilip Saket
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