本文介绍了如何使用ENABLE_BITCODE编译OpenCV iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 当我尝试使用XCode 7 + iOS SDK 9使用OpenCV 2.4 iOS编译我的XCode项目时,XCode抱怨When I tried to compile my XCode project with OpenCV 2.4 iOS using XCode 7 + iOS SDK 9, XCode complained that clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)clang: error: linker command failed with exit code 1 (use -v to see invocation)并拒绝链接。经过一些谷歌搜索后,结果因为Apple在App Store中添加了一个名为Bitcode的新功能,用于优化应用程序。虽然OpenCV iOS二进制文件尚未更新为包含Bitcode,但它无法通过链接阶段。and refused to link. After some googling, it turns out to be because Apple added a new feature named Bitcode for app optimization within App Store. While OpenCV iOS binary hasn't been updated to include Bitcode, it cannot pass the link stage.一些参考指出了一个临时解决方案来禁用 ENABLE_BITCODE 所以可以在没有Bitcode的情况下完成链接。这将阻止为Apple Watches编译应用程序,因为Bitcode对于Watch Apps是强制性的。因此我的问题是,是否有一些(最简单的)方法来编译启用Bitcode的iOS OpenCV? (更好的是使用编译框架的下载链接)Some reference pointed out a temporary solution to disable ENABLE_BITCODE so the linking could be done without Bitcode. This will prevent the app being compiled for Apple Watches because Bitcode is mandatory for Watch Apps. Therefore my question is, are there some (best easy) ways to compile iOS OpenCV with Bitcode enabled? (better with a download link for compiled framework)推荐答案经过一些搜索和试用,我想出了一种编译OpenCV iOS的方法来自Bitcode的来源。此处还提供了编译的二进制文件: [v3.0] [v2.4] 。 [免责声明:我不负责编译二进制文件的完整性。使用风险自负。]After some search and trial, I figured out a way to compile OpenCV iOS from the source with Bitcode. A compiled binary is also provided here: [v3.0] [v2.4]. [Disclaimer: I am not responsible for the integrity of the compiled binary. Use at your own risk.]编译步骤与官方文档,只需一步。The steps of compilation is basically the same as the official document, with only one extra step. 使用git下载代码:Download the code with git: cd~ /< my_working_directory> git clone https://github.com/Itseez/opencv.git为Xcode创建符号链接,让OpenCV构建脚本找到编译器,头文件等。Make symbolic link for Xcode to let OpenCV build scripts find the compiler, header files etc. cd / sudo ln -s /Applications/Xcode.app/Contents/Developer Developer [关键步骤] 更改编译脚本以添加Bitcode的额外选项:编辑〜/< my_working_directory> /opencv/platform/ios/build_framework.py ,找到包含 -DCMAKE_C_FLAGS 的行。添加 -fembed-bitcode 的标志。例如,在我得到的来源中,它是第55行,并且看起来像[Key Step] Change the compilation script to add the extra option for Bitcode: edit ~/<my_working_directory>/opencv/platform/ios/build_framework.py, and locate the line containing -DCMAKE_C_FLAGS. Add a flag of -fembed-bitcode. For example, in the source I got, it's line 55, and will look like - DCMAKE_C_FLAGS = \-Wno-implicit-更改后,函数声明-fembed-bitcode \+。 [ref]构建OpenCV框架:Build OpenCV framework: cd~ /< my_working_directory> python opencv / platforms / ios / build_framework.py ios如果一切正常,几分钟后你会得到〜/< my_working_directory> /ios/opencv2.framework 。您可以将此框架添加到Xcode项目中。If everything’s fine, a few minutes later you will get ~/<my_working_directory>/ios/opencv2.framework. You can add this framework to your Xcode projects. P.S。问一个问题,即使你已经知道答案是根据这篇文章。P.S. Ask a question, even when you already know the answer is encouraged according to this post on Meta Stackchange. 这篇关于如何使用ENABLE_BITCODE编译OpenCV iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-10 21:23