Ask Your Question
1

Error when importing the iOS framework

asked 2012-07-16 11:48:55 -0600

wonwoolee gravatar image

updated 2012-07-17 16:54:05 -0600

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 ?

edit retag flag offensive close merge delete

Comments

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

LunarDuck gravatar imageLunarDuck ( 2014-09-02 19:11:24 -0600 )edit

No, we have framework only for iOS.

AlexanderShishkov gravatar imageAlexanderShishkov ( 2014-09-05 07:06:06 -0600 )edit

4 answers

Sort by ยป oldest newest most voted
1

answered 2012-07-17 16:46:06 -0600

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.

edit flag offensive delete link more
0

answered 2013-05-17 09:16:19 -0600

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...

edit flag offensive delete link more
0

answered 2012-07-19 06:11:06 -0600

wonwoolee gravatar image

updated 2012-07-19 06:12:27 -0600

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 ?

edit flag offensive delete link more
0

answered 2012-07-17 16:56:16 -0600

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2012-07-16 11:48:55 -0600

Seen: 4,153 times

Last updated: May 17 '13