Computer Vision Talks All you want and should know about computer vision is here

21Mar/1135

OpenCV build script with XCode 4 support is here

opecv-plus-apple

Yes, i did it! Now with XCode 4 and iOS 4.3 support.
OpenCV Build Script (7552)
There were a few changes in XCode 4. Some of them break down previous build script. Anyway, new version of build script works well. Tested on OpenCV 4817 revision. As always, any comments, bugreports and suggestions are welcome. If you experiencing any problems with it, please specify version of xcode and opencv revision number.

Important Update

Sample XCode 4 iOS project that uses OpenCV is published: XCode iOS OpenCV template project (3164)

Comments (35) Trackbacks (2)
  1. Excellent, thank you very much

  2. Good job! Have you tested it on device?

  3. Yep :) I use OpenCV for my realtime markerless AR.
    But since i use automated build system (Jamplus) i do not have all these problems with XCode like you guys.

  4. Not using Xcode 4, but 3.2.6 and I have similar troubles.
    With your latest build everything is better, but…
    at link time it looks for haartraining lib.
    I do not reference it, thought.

    ld: library not found for -lopencv_haartraining_engine
    collect2: ld returned 1 exit status
    Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.2 failed with exit code 1

    My config : xcode 3.2.6, BloodAxe-opencv-ios-template-project-bc5e130
    I copied your opencv dir in my project.

  5. Can you show your command line for link stage?

    ld: library not found for -lopencv_haartraining_engine is definitely means that haartraining is included in build somewhere. There are three ways to pass libraries to linker:
    1) Through XCode gui (drag static libs to “Link with static libraries” target)
    2) Through additional linker input (In the project settings)
    3) Using #pragma comment lib

    Just find and remove unnecessary reference from linker input.

  6. Should this project work out of the box, or does it still need the libraries compiling and adding to the project? Sorry for the newbie question – I’ve been using pre-compiled libraries from niw.at up until now, but the build version doesn’t work on the device.

  7. Yes it should. Tested on my device.

  8. Static libs already included

  9. Well. massive props for getting this working. I’m currently doing some SURF stuff, and although I’m pretty much a complete newcomer to computer vision, it is fascinating. Some of your videos (especially the LAZY ones!) are great. Alas, I seem to be having the problem building for device, I think at the linker stage (seems fine on simulator).

    I’m using build Build 4A304a of xcode 4. Here comes the error:

    Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 failed with exit code 1

    ld: in /Users/leonard/Development/opencv-ios-template-project/opencv/lib/debug-universal/liblibjasper.a, file is universal but does not contain a(n) armv6 slice for architecture armv6
    collect2: ld returned 1 exit status
    Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 failed with exit code 1

  10. Quick update: On the build settings I changed “Build Active Architecture Only” to “Yes” and it built and ran on my iPhone correctly :)

  11. Switch to armv7 architecture in XCode, because armv6 is deprecated one

  12. Hi. I downloaded new build script from
    https://github.com/BloodAxe/OpenCV-iOS-build-script
    with armv6 architecture support.

    But there is a tiny bug in it. When it tries to make universal libs it can’t find files:
    -> for FILE in `ls $BUILD/lib/release-iphoneos`
    I changed it with
    -> for FILE in `ls $BUILD/lib/release-iphoneos-armv7`
    and all is fine for me :)

    Thanks for your great work.

  13. Hi. Thanks for your script, it worked, I build my own library, but when I try to build any project with my library i get this error:
    ld: library not found for -lopencv_lapack
    collect2: ld returned 1 exit status
    Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.2 failed with exit code 1

    but if I try with your precompiled libraries it works.

    But with your library every time I get a runtime error I get a message like this

    OpenCV Error: Assertion failed (src.channels() == dst.channels()) in cvCopy, file /Users/bloodaxe/develop/opencv-library/opencv_build_4817/tmp/ios-sources-patched/opencv/modules/core/src/copy.cpp, line 552
    terminate called after throwing an instance of ‘cv::Exception’
    what(): /Users/bloodaxe/develop/opencv-library/opencv_build_4817/tmp/ios-sources-patched/opencv/modules/core/src/copy.cpp:552: error: (-215) src.channels() == dst.channels() in function cvCopy

    How can I change the path from
    /Users/bloodaxe/develop/opencv-library/opencv_build_4817/tmp/ios-sources-patched/opencv/modules
    to my folder?

  14. Hi. Can you give some advice on the usage of this script?

    bash Build-OpenCV.sh

    “Error in $0 – Invalid Argument Count”
    “Syntax: $0 [OpenCV source directory] [Build destination directory]”
    “If the destination directory already exists, it will be overwritten!”

  15. Hey All,

    Just got the opencv 2.3 Binaries and I am trying to figure out how to get them to work. I am getting the ‘map’ file not found and a bunch of semantic issues. I am using .mm for the file that has the include opencv2… I can get just the opencv/cv.h file included and working, but not the opencv2.

    Any help would be appreciated

  16. OK still clueless :) I can get your template running without an issue and it looks almost identical to my project. Here are the steps I have taken.
    1. Download opencv 2.3

    2. Create new project (single view)

    3. Add files -> lib and include. (Note i got ride of parent folder)

    4. HEADER_SEARCH_PATHS = “$(SRCROOT)/include

    5. LIBRARY_SEARCH_PATHS = $(inherited) “$(SRCROOT)/lib/debug-universal” “$(SRCROOT)/lib/release-universal”

    6. OTHER_LDFLAGS = -llibjasper -llibjpeg -llibpng -llibtiff -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_imgproc -lopencv_lapack -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_video -lzlib

    7. Change main view controller to .mm (I also tried changing Delegate in addition to mm with no luck)

    8. At this point I paste #include to the header of the view controller and get errors like map file not found and
    core.hpp: non-const static data member must be initialized out of line [3].

    Is it not treating these files as c++ when parsing? I noticed in your project you have the include opencv.. inside of a cpp file which is imported by an .mm I have tried that also with no luck. Any ideas?

    • Some Progress! Switched compiler to LLVM GCC 4.2. Still have a few small errors and the Statement-expressions are allowed only inside functions error. Getting there

      • Got it working! Anyone else who has this problem check your .pch file and make sure you do have have any include statements.

        Thanks

        • Thank you very much! I had same problems trying to use OpenCV in C++ on XCode. I had to add in the .pch file #import “opencv2/opencv.hpp” as first import, change main.m to main.mm and also change the compiler to LLVM GCC 4.2 as you said.

  17. Hi Taino,

    how did you manage to fix it? I managed to include the libraries and eliminate the linking problems (no library found) but I still get Statement-expressions error (tried with both compiles GCC and LLVM GCC).

    I removed all imports from the .pch file.

    Any ideas?

  18. Freaking hell… the sooner I ask the sooner I find the solution.

    In case anyone else is fighting with this:

    If you mange to resolve all linking problems and iostream problems but still get the Statement-expression error…. you need to include the opencv BEFORE any other import.

    Found it here:
    http://stackoverflow.com/questions/3810800/how-to-include-opencv-in-cocoa-application

  19. Hi all,
    the project (GLImagePROCESSING) HAS BEEN BUILT only without the opencv code, while when I insert:
    // Matrix Utilities for Hue rotation
    static void matrixmult(float a[4][4], float b[4][4], float c[4][4])
    {
    cv::Mat(4,4,CV_32FC1, c) = cv::Mat(4,4,CV_32FC1, a) * cv::Mat(4,4,CV_32FC1,b);
    }

    Th error is:
    Check dependencies

    [BEROR]No architectures to compile for (ARCHS=i386, VALID_ARCHS=armv6 armv7).

    How can I set armv6 o armv7 ARCHS instead og i386?

    Thanks a lot

    Dario

  20. Hi all,
    the project (GLImagePROCESSING) HAS BEEN BUILT only without the opencv code, while when I insert:
    // Matrix Utilities for Hue rotation
    static void matrixmult(float a[4][4], float b[4][4], float c[4][4])
    {
    cv::Mat(4,4,CV_32FC1, c) = cv::Mat(4,4,CV_32FC1, a) * cv::Mat(4,4,CV_32FC1,b);
    }
    Th error is:
    Check dependencies
    [BEROR]No architectures to compile for (ARCHS=i386, VALID_ARCHS=armv6 armv7).
    How can I set armv6 o armv7 ARCHS instead og i386?
    Thanks a lot
    Dario

  21. Hello,
    sorry, I’m kind of newbie with compilation scripts, but I didnt understand very well in this command:
    sh BuildOpenCV.sh trunk/opencv/ opencv_ios_build
    where will be the opencv_ios_build folder? and it will be a empty folder?
    I tryed to run the script but give those errors bellow….please help me :)

    MacBook-de-Igor-Pontes:opencv-library igorpontes$ sh BuildOpenCV.sh opencv/ opencv_ios_build/
    OpenCV source : /Users/igorpontes/Igor/Downloads/opencv-library/opencv
    Build directory : /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build
    Intermediate dir: /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp
    Patched source : /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-sources-patched
    WARNING: The bulid directory will be removed and re-created again.
    WARNING: It’s your last chance to check is it correct and you do not have anything valuable in it.
    Press any key to continue…

    Installing OpenCV headers
    CMake Error: Error: generator : Xcode
    Does not match the generator used previously: Unix Makefiles
    Either remove the CMakeCache.txt file or choose a different binary directory.
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/mac-build does not contain an Xcode project or workspace.

    mv: rename /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/mac-install/include/* to /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/include/*: No such file or directory
    Patching OpenCV sources
    CMake Error: The current CMakeCache.txt directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-sources-patched/CMakeCache.txt is different than the directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
    Building iphone release armv6 configuration
    building zlib
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libjpeg
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libpng
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libtiff
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libjasper
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_calib3d
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_core
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_features2d
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_flann
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_imgproc
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_legacy
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_contrib
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_ml
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_objdetect
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_video
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    mv: rename /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build/lib/Release/*.a to /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/lib/release-iphoneos-armv6/*.a: No such file or directory
    mv: rename /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build/3rdparty/lib/Release/*.a to /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/lib/release-iphoneos-armv6/*.a: No such file or directory
    Building iphone debug armv6 configuration
    building zlib
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libjpeg
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libpng
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libtiff
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libjasper
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_calib3d
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_core
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_features2d
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_flann
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_imgproc
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_legacy
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_contrib
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_ml
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_objdetect
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_video
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    mv: rename /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build/lib/Debug/*.a to /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/lib/debug-iphoneos-armv6/*.a: No such file or directory
    mv: rename /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build/3rdparty/lib/Debug/*.a to /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/lib/debug-iphoneos-armv6/*.a: No such file or directory
    Building iphone simulator release configuration
    building zlib
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libjpeg
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libpng
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libtiff
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libjasper
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_calib3d
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_core
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_features2d
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_flann
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_imgproc
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_legacy
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_contrib
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_ml
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_objdetect
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_video
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    mv: rename /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build/lib/Release/*.a to /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/lib/release-iphonesimulator/*.a: No such file or directory
    mv: rename /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build/3rdparty/lib/Release/*.a to /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/lib/release-iphonesimulator/*.a: No such file or directory
    Building iphone simulator debug configuration
    building zlib
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libjpeg
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libpng
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libtiff
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libjasper
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_calib3d
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_core
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_features2d
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_flann
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_imgproc
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_legacy
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_contrib
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_ml
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_objdetect
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_video
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    mv: rename /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build/lib/Debug/*.a to /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/lib/debug-iphonesimulator/*.a: No such file or directory
    mv: rename /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build/3rdparty/lib/Debug/*.a to /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/lib/debug-iphonesimulator/*.a: No such file or directory
    Building iphone debug armv7 configuration
    building zlib
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libjpeg
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libpng
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libtiff
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libjasper
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_calib3d
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_core
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_features2d
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_flann
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_imgproc
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_legacy
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_contrib
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_ml
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_objdetect
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_video
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    mv: rename /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build/lib/Debug/*.a to /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/lib/debug-iphoneos-armv7/*.a: No such file or directory
    mv: rename /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build/3rdparty/lib/Debug/*.a to /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/lib/debug-iphoneos-armv7/*.a: No such file or directory
    CMake Error: The current CMakeCache.txt directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-sources-patched/CMakeCache.txt is different than the directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
    Building iphone release armv7 configuration
    building zlib
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libjpeg
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libpng
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libtiff
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building libjasper
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_calib3d
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_core
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_features2d
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_flann
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_imgproc
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_legacy
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_contrib
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_ml
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_objdetect
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    building opencv_video
    xcodebuild: error: The directory /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build does not contain an Xcode project or workspace.

    mv: rename /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build/lib/Release/*.a to /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/lib/release-iphoneos-armv7/*.a: No such file or directory
    mv: rename /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/tmp/ios-build/3rdparty/lib/Release/*.a to /Users/igorpontes/Igor/Downloads/opencv-library/opencv_ios_build/lib/release-iphoneos-armv7/*.a: No such file or directory
    All is done

    thanks
    Igor

  22. Super awesome. Getting my hands dirty now

  23. Hey,

    I’m seeing some strange behaviour when trying to repro your build of OpenCV 2.3 with this build script. Specifically, everything works fine, but the Release binaries generated seem to be Debug binaries (in fact, if you run the script then go to /tmp/ios-dev-build/lib/Release, all the libs in there seem to actually be symlinks to the debug versions!

    I’ve solved this locally by opening the generated xcodeproj, manually hammering the optimization settings of every release build to be -Os, and removing the GCC_OPTIMIZATION_LEVEL define, which seems to be defined as zero even in the release config, then building the XcodeProj manually.

    I needed to compile OpenCV locally because (a) Instruments doesn’t recognize symbols from your prebuilt lib and (b) I needed to make some performance optimizations to some OCV functions. I’ve verified that this issue happens when I build any version of OpenCV, even the 2.4 release candidate (in fact, initially I thought the issue was some horrible performance loss in OCV 2.4, which was why I synced svn manually to rev 7599 to try to replicate your build.)

    Have you seen this same issue or do you know what might be causing it?

    Thanks,
    Alex.

    PS. What SVN Release did you use to approximate the 2.3 release whilst having the native iOS build files in the opencv/ios folder? They were added after the 2.3 release, so Releases/2.3 won’t build with this script – did you just build the ios branch? It doesn’t hugely matter though, as I may now just upgrade to the official 2.4 release now that I can explain the performance issue.

    • Hi Alex,
      Thanks for your feedback. I’ll check your suspections and keep you informed.
      Regards, Eugene.

      • It seems to be related to the install step – if I run the script and watch the tmp/ios-dev-build/lib/Release folder, I an see that the libs all get built, then during the install step they’re turned into symlinks.

        If we follow those symlinks, we get this…

        Alex-Ferriers-MacBook-Pro:Release Alex$ readlink ./libopencv_calib3d.a
        /Users/Alex/src/ColouredString/opencv/opencv/build/ios/tmp/ios-dev-build/modules/calib3d/UninstalledProducts/libopencv_calib3d.a

        Now, I haven’t traced back further, but there’s only one lib in the “UninstalledProducts” folder, and it is definitely the debug lib.

        This isn’t a huge deal breaker for me anyway, as for now I’ve just not bothered with the install step and pointed my linker directly into the tmp folder.

    • Hi Alex,

      I tried to build the OpenCV 2.4 beta, and i can say that GCC optimization is enabled. Here is a proof:

      CompileC /Users/bloodaxe/Develop/opencv-2.4-build/tmp/ios-dev-build/modules/core/OpenCV.build/Release-iphoneos/opencv_core.build/Objects-normal/armv7/lapack.o modules/core/src/lapack.cpp normal armv7 c++ com.apple.compilers.llvmgcc42
      cd /Users/bloodaxe/Develop/2.4/opencv
      setenv LANG en_US.US-ASCII
      setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin"
      /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2 -x c++ -arch armv7 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -O3 "-DCMAKE_INTDIR=\"Release-iphoneos\"" -DHAVE_CVCONFIG_H -DHAVE_ALLOCA -DHAVE_ALLOCA_H -DHAVE_LIBPTHREAD -DHAVE_UNISTD_H -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk -mthumb -miphoneos-version-min=5.1 -I/Users/bloodaxe/Develop/opencv-2.4-build/tmp/ios-dev-build/lib/Release/include -I/Users/bloodaxe/Develop/opencv-2.4-build/tmp/ios-dev-build/3rdparty/zlib -I/Users/bloodaxe/Develop/2.4/opencv/3rdparty/zlib -I/Users/bloodaxe/Develop/opencv-2.4-build/tmp/ios-dev-build/modules/core -I/Users/bloodaxe/Develop/2.4/opencv/modules/core/src -I/Users/bloodaxe/Develop/2.4/opencv/modules/core/include -I/Users/bloodaxe/Develop/opencv-2.4-build/tmp/ios-dev-build -I/Users/bloodaxe/Develop/opencv-2.4-build/tmp/ios-dev-build/modules/core/OpenCV.build/Release-iphoneos/opencv_core.build/DerivedSources/armv7 -I/Users/bloodaxe/Develop/opencv-2.4-build/tmp/ios-dev-build/modules/core/OpenCV.build/Release-iphoneos/opencv_core.build/DerivedSources -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -F/Users/bloodaxe/Develop/opencv-2.4-build/tmp/ios-dev-build/lib/Release -headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden -c /Users/bloodaxe/Develop/2.4/opencv/modules/core/src/lapack.cpp -o /Users/bloodaxe/Develop/opencv-2.4-build/tmp/ios-dev-build/modules/core/OpenCV.build/Release-iphoneos/opencv_core.build/Objects-normal/armv7/lapack.o

      The -O3 flag is passed to compiler as it should be.

      • I’m having the same issue as Alex. The latest SVN gets compiled with -O0. Do you have any special tweaks in your env that it works for you?


Leave a comment

(required)