在XCode上使用定制的OpenCV for iOS会生成___sincos_stret未定义的符号

我正在尝试在我的iPhone应用程序中使用C ++静态库,该应用程序使用iOS版本的OpenCV的修改版本,并且在链接时遇到此问题:

Undefined symbols for architecture armv7: "___sincos_stret", referenced from: cv::initInterTab2D(int, bool) in opencv2(imgwarp.o) ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation) 

我真的不明白我在想什么,这个函数似乎并不存在于OpenCV中,我也没有在networking上find任何有意义的东西。 我想知道是否在某个math图书馆,但我还没有find任何东西。

我已经用Clang编译OpenCV并使用默认的libc ++库。

libmylibrary.a和OpenCV2框架在链接库列表中正确。

我是XCode的新手,因此我可能在编译静态库和/或将其链接到我的项目中遗漏了一些微不足道的东西。

我没有改变该对象的源代码,因为我的变化与OpenCV的imgproc模块的另一部分有关,所以我猜想即使使用默认版本,也可能发生这种情况。

你有什么线索吗?

在安装了XCode 5开发人员预览版并使用build_framework.py脚本构buildOpenCV之后,我遇到了这个问题。 ___sincos_stret似乎来自使用新的编译器版本。

我通过更改命令行工具的path来解决此问题。

在terminal中,validationXCode命令行path:

 xcode-select --print-path 

如果它在XCode5-DP.app内打印path,则切换到Xcode 4的工具:

 xcode-select --switch /Applications/XCode.app/Contents/Developer 

并重build框架。 然后尝试重新编译项目。

为了解决Xcode 5工具链中的这个问题,我将支持的最小iOS版本指定为编译器选项,以匹配Xcode中的configuration。 例如:

 -miphoneos-version-min=5.0 

您可以将其添加到makefile中的C和CXX标志

 CFLAGS += -miphoneos-version-min=5.0 CXXFLAGS += -miphoneos-version-min=5.0 

对于那些不想用较低版本的XCode构build的用户,请尝试更改OpenCV iOS的python构build脚本。 在build_framework.py中,我添加了IPHONEOS_DEPLOYMENT_TARGET=6.0 ,重build了OpenCV for iOS。

 os.system("xcodebuild -parallelizeTargets ARCHS=%s -jobs 8 -sdk %s -configuration Release -target ALL_BUILD" % (arch, target.lower())) os.system("xcodebuild ARCHS=%s -sdk %s -configuration Release -target install install" % (arch, target.lower())) 

要得到

 os.system("xcodebuild IPHONEOS_DEPLOYMENT_TARGET=6.0 -parallelizeTargets ARCHS=%s -jobs 8 -sdk %s -configuration Release -target ALL_BUILD" % (arch, target.lower())) os.system("xcodebuild IPHONEOS_DEPLOYMENT_TARGET=6.0 ARCHS=%s -sdk %s -configuration Release -target install install" % (arch, target.lower())) 

对我来说,解决了这个问题。 阅读__sincos_stret这个符号

TODO:虽然解决了这个问题,但是在python脚本生成的OpenCV.xcodeproj(在build文件夹中),它仍然具有iOS 7.0的部署目标。 可能有一个更干净的方法。

通过在其他地方支持Adam的问题进行快速search,该符号在[path to SDK]/usr/lib/system/libsystem_m.dylib定义。 certificate:

 nm /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/lib/system/libsystem_m.dylib | grep sincos 

而不是坚持旧版本的工具或SDK,只要确保你的链接反对。