Ask Your Question
1

Error when importing the iOS framework

asked Jul 16 '12

wonwoolee gravatar image

updated Jul 17 '12

AlexanderShishkov gravatar image

Hello.

I downloaded the official version of iOS framework from the link on opencv.org.

I created a simple view-based XCODE project and added the opencv2.framework in the build phases menu.

Then I imported opencv2.framework as

#import "opencv2/opencv.hpp"
in the *.pch file.

When I ran build, some error occurs like these:

/Users/wlee/Downloads/opencv2.framework/Versions/A/Headers/video/background_segm.hpp
Unknown type name 'namespace'
Expected ';' after top level declarator
/Users/wlee/Downloads/opencv2.framework/Versions/A/Headers/objdetect/objdetect.hpp
Unknown type name 'CvHaarFeature'

Did I do anything wrong ?

Preview: (hide)

Comments

is there a precompiled framework of OpenCV for OSX? where I can download it?

LunarDuck gravatar imageLunarDuck (Sep 3 '14)edit

No, we have framework only for iOS.

4 answers

Sort by » oldest newest most voted
1

answered Jul 17 '12

hkaraoguz gravatar image

Hi,

My .pch file is like this:

#import <Availability.h>
#ifndef __IPHONE_4_0
#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif

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

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
#endif

and it works without any problems.

Preview: (hide)
0

answered May 17 '13

PitOn gravatar image

Hi, guys.

Tried all these variants above but no luck. Still produces such errors:

Expected '(' for function-style cast...

in mat.hpp and operations.hpp...

Preview: (hide)
0

answered Jul 19 '12

wonwoolee gravatar image

updated Jul 19 '12

Thanks, guys. I solved the problem.

It seems that all the files in a project should be C++. (using *.mm and *.cpp)

If there are some *.m or *.c files, the namespace errors occur in my project.

Anybody knows about this issue ?

Preview: (hide)
0

answered Jul 17 '12

AlexanderShishkov gravatar image

My .pch:

#import <opencv2/opencv.hpp>

#import <Availability.h>

#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
#endif

You should try to include OpenCV framework before any definitions on your .pch file.

Preview: (hide)

Question Tools

1 follower

Stats

Asked: Jul 16 '12

Seen: 4,313 times

Last updated: May 17 '13