xcode 导入包含 OPENCV 函数的 STATIC LIBRARY 时出现“架构 armv7 的未定义符号”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16240620/
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
"Undefined symbols for architecture armv7" when importing STATIC LIBRARY that contains OPENCV functions
提问by marcelosalloum
I developed a very simple application, using openCV for IOS. It worked until I decided to use the code in other project. I am getting this armv7 error and I can't see where is the problem (please, see last image)
我开发了一个非常简单的应用程序,使用 openCV for IOS。它一直有效,直到我决定在其他项目中使用该代码。我收到此 armv7 错误,但看不到问题出在哪里(请参阅最后一张图片)
I created a static lib file of my working code, which has the following architecture info:
我为我的工作代码创建了一个静态 lib 文件,其中包含以下架构信息:
Than I compiled it into a *.a file and added the dyOpenCv.aand a DyOpenCV.hfiles to my main project, which has the following architecture information:
然后我将它编译成一个 *.a 文件并将dyOpenCv.a和一个DyOpenCV.h文件添加到我的主项目中,它具有以下架构信息:
But when I try to use the method within the header file (DyOpenCV.h), the following error appears:
但是当我尝试在头文件(DyOpenCV.h)中使用该方法时,会出现以下错误:
Any Ideas of what may it be?
任何想法可能是什么?
回答by marcelosalloum
There were two issues related to linking libraries:
有两个与链接库相关的问题:
Firstly, although my subproject had the opencv2.frameworkcorrectly added and linked to it, I also had to add this framework to my main project. This way I got rid of the cv::*linking problems;
The second issue was related to my crossing compiler Objective-C++ configuration. Once I was using libc++ as my Standard Library, I added -lc++ to my Other Linker Flags. In case you are using libstdc++ as your Standard Library, you should add -lstdc++ instead.
首先,虽然我的子项目 正确添加并链接了opencv2.framework,但我还必须将此框架添加到我的主项目中。这样我就摆脱了cv::*链接问题;
第二个问题与我的交叉编译器 Objective-C++ 配置有关。一旦我使用 libc++ 作为我的标准库,我将 -lc++ 添加到我的Other Linker Flags。如果您使用 libstdc++ 作为标准库,则应添加 -lstdc++。
After That, it worked perfectly. Although there were some memory leaks to take care of =)
在那之后,它完美地工作。虽然有一些内存泄漏需要处理 =)
Cheers,
干杯,
回答by Jinah Adam
I think its because ur project is not linking to the C++ runtime .
我认为这是因为你的项目没有链接到 C++ 运行时。
Try adding libc++.dylib to ur linked Libraries.
尝试将 libc++.dylib 添加到您链接的库中。