OpenCV.Framework does not compile for the armv7s architecture

后端 未结 7 1834
北恋
北恋 2021-02-02 13:34

I am working on an iphone application using openCV framework. Everything was working fine. however lately with the release of iOS 6 and XCode 4.5 I was migrating my project to X

相关标签:
7条回答
  • 2021-02-02 14:12

    Stating the obvious, you will need to recompile and rebuild the library openCV.framework and target it for armv7s.

    Adjust the library "project settings" and "target settings" before rebuild. good luck!

    0 讨论(0)
  • 2021-02-02 14:15

    This answer builds upon the one given by n9986. As he suggested, I cloned the repository found at

    https://github.com/jonmarimba/OpenCV-iOS

    When I downloaded it several references inside the project to different libraries were broken which was strange but they were easy to fix. After they were fixed it behaved exactly as n9986 described, outputting libraries compiled for both armv7 and armv7s. For my purposes however I required that they be bundled into a .framework so that they could be a drop in replacement for the old .framework I have been using.

    Previously I had downloaded the latest version of Opencv for ios here and spent quite a bit of time trying to modify their cmake files to compile with support for armv7s. jonmarimba has already restructured the xcode project file to strip away its cmake dependencies which makes changing the target architecture much more intuitive. Unfortunately he does not build as many libraries as come with the standard openCV build. I added a new target to jonmarimba's project for opencv_world which is the target used in the standard openCV release for converting into a framework. Once that was built I used it as a drop in replacement for the static library in the framework file structure generated by the standard openCV release.

    The framework I created can be downloaded here. It works perfectly for me as a drop in replacement for my previous opencv2.framework. I did notice however that jonmarimba has not converted the targets for opencv_videostab, opencv_stitching, or opencv_nonfree. It is possible that if you use one of those libraries my framework will not work for you. If that is the case let me know and I can try to set those up as targets in the xcode project for you.

    Update

    To compile for other architectures, change the target architecture in the included xcode project to whatever you like for the opencv_world library. After you build it, go find the library you just built. Rename the opencv_world library to opencv2 and replace the library file found in the .framework with opencv_world.

    Update2

    OpenCV 2.4.3 now compiles with armv7s support by default so these solutions are outdated.

    0 讨论(0)
  • 2021-02-02 14:19

    Clone the Xcode project for opencv and update the opencv git submodule as per the README:

    https://github.com/jonmarimba/OpenCV-iOS

    Check the build settings, make sure iOS6 and armv7s are present. Click build. You should now have the armv7s compatible .a files. I just tried this:

    $ file libopencv_core.a 
    libopencv_core.a: Mach-O universal binary with 2 architectures
    libopencv_core.a (for architecture armv7):  current ar archive random library
    libopencv_core.a (for architecture cputype (12) cpusubtype (11)):   current ar archive random library
    

    The last entry is for armv7s as per my research so far.

    Edit: The last entry is indeed armv7s. I ran the Xcode's own lipo info command:

    $ xcrun -sdk iphoneos lipo -info libopencv_core.a 
    Architectures in the fat file: libopencv_core.a are: armv7 armv7s 
    
    0 讨论(0)
  • 2021-02-02 14:23

    You can always just not target armv7s, and only target armv7. Your application will still run fine on the iPhone 5, it just won't be fully optimized for the new instruction set.

    0 讨论(0)
  • 2021-02-02 14:23

    Pass -DCMAKE_OSX_ARCHITECTURES="armv6;armv7;armv7s;i386" to cmake when compiling OpenCV library/framework for iOS.

    0 讨论(0)
  • 2021-02-02 14:27

    Probably its possible to build it with CMake. I had one year ago a problem with a medical library I wanted to build for iOS. I could handle that with CMake.

    Perhaps this link can be a starter.

    http://computer-vision-talks.com/2010/12/building-opencv-for-ios/

    Good luck!

    0 讨论(0)
提交回复
热议问题