Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9079779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:55:00+00:00 2026-06-16T19:55:00+00:00

openCV 2.4.3 / Xcode 4.5.2 / mac osx 10.8.2 I am trying to get

  • 0

openCV 2.4.3 / Xcode 4.5.2 / mac osx 10.8.2

I am trying to get openCV working with iOS. I am attempting to use the the prebuilt 2.4.3 framework from openCV.org. However I am getting the following xcode project build errors that suggest the compiler doesn’t know it is dealing with c++, eg

#include <list>       !'list' file not found

namespace cv          !unknown type name 'namespace'

This only seems to concern the following header files:
“opencv2/nonfree/features2d.hpp”
“opencv2/nonfree/nonfree.hpp”
“opencv2/video/video.hpp”

if I don’t include these three files in opencv.hpp (or anywhere else) I seem to be able to compile and use openCV ok. The trouble is, I do need the nonfree files as I am experimenting with SURF – which has been moved to nonfree recently.

This is really a twofold question (sorry 😉

  • how do I convince the compiler that these are c++ headers?
  • which headers exactly do I need to use SURF?

update

I have cloned the openCV git repository and built a new framework from that. This approach had not worked previously, but today I realised that I was not using the current version of CMAKE. I had been using CMAKE 2.8.2 and this would fail to build opencv for ios. Current version CMAKE 2.8.10 builds it without any issues (that’s an object lesson in obeying the docs, which do say CMAKE min. v2.8.8 is required).

Now when I add this current build of the opencv framework in an Xcode project I can include features2d and nonfree and build smoothly. The only problem remains with one header: video/background_segm.hpp, which still yields:

#include <list>       !'list' file not found

If I comment that line out I get an error on the next line:

namespace cv          !unknown type name 'namespace'

It seems clear that the compiler doesn’t recognise this as a C++ header, even though it is suffixed .hpp.

In opencv2/video/video.hpp if I remove

#include "opencv2/video/background_segm.hpp"

I can build with video.hpp also (although I guess it would be unusable in practice).

Unfortunately I still can’t get SURF to work. When I run the project it crashes with this error:

OpenCV Error: The function/feature is not implemented (OpenCV was built without SURF support)

This is triggered in legacy/features2d.cpp:

   Ptr<Feature2D> surf = Algorithm::create<Feature2D>("Feature2D.SURF");
   if( surf.empty() )
        CV_Error(CV_StsNotImplemented, "OpenCV was built without SURF support");

The questions remain…

  • how do I convince the compiler that background_segm.hpp is a legit c++ header?
  • how do I enable SURF support?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:55:02+00:00Added an answer on June 16, 2026 at 7:55 pm

    I have everything working now. After having no joy with the pre-built iOS library available from openCV.org this is what I did…

    • compile openCV for iOS from a clone of the gitHub repository. Run build_framework.py (in the ios folder of the distribution), pointing to an output directory of your choosing. Be sure to have an up-to-date copy of CMake or you will trip over like I did.

    • Your output folder will end up with two subfolders, build and opencv2.framework. Drag the latter into your Xcode project

    Add the following line in the project-Prefix.pch file

    #ifdef __cplusplus
    #import <opencv2/opencv.hpp>
    #endif
    

    (should go above the #ifdef __OBJC__ line)

    That is sufficient to get most of openCV working. However it is a very good idea to avoid “objective-C++” (mixing your c++ code in the same files as your objective-C). To manage this you create a thin “wrapper” object (which will be obj-C++) to mediate between your obj-C classes and c++ code. The wrapper essentially has only two roles: to translate data formats (eg UIImage <-> cv::Mat), and to translate between obj-C methods and C++ function calls. See my answer to this question for details (and a github-hosted example project)

    To get SURF (and SIFT) working requires a couple of additional steps, as SURF is somewhat deprecated due to licensing issues (it’s been moved into nonfree which does not load automatically).

    These includes need to be added in files where you are using SURF

    #include <opencv2/nonfree/nonfree.hpp>
    #include <opencv2/legacy/compat.hpp>
    

    The code I am working with uses the C interfaces for SURF (eg cvExtractSURF), so we also need to add this line before calling these functions:

       cv::initModule_nonfree();
    

    The other part of my question, how to force Xcode to compile as C++, was a bit of a red herring (there must have been something compatibility issue with the openCV build I was using) – and is no longer required for this solution. However the answer is first, to rename your .m files .mm (for objective-C++) or .cpp (for pure C++) … but if that doesn’t work, you can force the issue in the file inspector by changing ‘file type’.

    update

    You also need to take care that the C++ standard library is set correctly in any projects that use the openCV framework. Older versions of openCV (to.2.4.2) want libstdc++, newer (2.4.3+) expect libc++. Details here:

    https://stackoverflow.com/a/14186883/1375695

    update 2

    openCV now installs with cocoaPods. To quote SebastienThiebaud

    OpenCV is available on Cocoapods. Add one line in your Podfile: pod ‘OpenCV’. Pretty easy.

    “Pretty easy” … given all our previous hassles, could be the understatement of [last] year…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to install OpenCV on my Mac (OS X v10.6.3) for use
I'm using the OpenCV framework with XCode and want to convert from cvMat or
Im using Xcode and c++ I have copied the HoughCircles code from the OpenCV
I'm working with NITE/OPENNI and opencv in xcode 4 to work with the kinect.
Im creating a project in Xcode using OpenCV as a framework. It works great
I have been trying for hours to run an xcode project with openCV. I
I've been trying on and off for the past 6 months to get OpenCV
I'm trying to compile a project which uses OpenCV C++ code in Xcode. template<typename
I am working on an iphone application using openCV framework. Everything was working fine.
I'm currently developing an iOS App with OpenCV framework, everything's OK until I've tried

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.