Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build with opencv 3.1 in ios failed because of the enum name #6114

Closed
canius opened this issue Feb 15, 2016 · 10 comments

Comments

@canius
Copy link

@canius canius commented Feb 15, 2016

There is a conflict in stitching/detail/blenders.hpp line 63:
enum { NO, FEATHER, MULTI_BAND };

The enum name "NO" is conflict with the build-in BOOL type "NO" in iOS.
So an error occurred :
/opencv/Pods/OpenCV/opencv2.framework/Headers/stitching/detail/blenders.hpp:63:12: Expected identifier
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/usr/include/objc/objc.h:74:13: Expanded from macro 'NO'

@canius canius changed the title Build with opencv 3.1 in ios failed. Build with opencv 3.1 in ios failed because of the enum name Feb 15, 2016
@alalek

This comment has been minimized.

Copy link
Contributor

@alalek alalek commented Feb 15, 2016

Related #6047

If you don't need this module then try to replace opencv.hpp include to list if required modules.

@mshabunin mshabunin added the wontfix label Feb 16, 2016
@jmbapps

This comment has been minimized.

Copy link

@jmbapps jmbapps commented Feb 16, 2016

I had a similar issue with OS X, they said they would not fix that either. It was a conflict with an Apple macro 'check' and it was conflicting with a bool called 'check'. I imported the opencv files before the Foundation/Foundation. Try importing the opencv files before UIKIT/UIKIT in your ViewController and see if that helps. These guys love their 'wontfix' and said the same to me, so I figured it out myself. Good luck. Also if you are using Xcode, just download the iOS framework and add it to your project. I have a couple of apps that use the opencv framework in iOS.

@mshabunin

This comment has been minimized.

Copy link
Contributor

@mshabunin mshabunin commented Jul 12, 2016

Some kind of workaround has been introduced in PR #6161 - it will give you compilation warning with the explanation.

@avanish

This comment has been minimized.

Copy link

@avanish avanish commented Feb 9, 2017

It was still giving me the same error even when I imported opencv.hpp above UIKit. Importing it in .mm instead of .h works too. Or you could follow the one suggested by alalek.

Instead of importing opencv2/opencv.hpp, you can import the necessary modules separately.

@ctliu3

This comment has been minimized.

Copy link

@ctliu3 ctliu3 commented May 3, 2017

In 3.2.0, I also encounter this problem. I comment the corresponding modules in opencv.hpp and it works, at least for building. But I haven't test the correctness.

Update:
The result is correct.

@amayatsky

This comment has been minimized.

Copy link

@amayatsky amayatsky commented May 4, 2017

I have moved #import <opencv2/opencv.hpp> above all other imports as suggested and that did the trick.

@IgorKovr

This comment has been minimized.

Copy link

@IgorKovr IgorKovr commented May 16, 2017

if you're not using stitching.hpp just comment the line 86 of opencv.hpp
//#include "opencv2/stitching.hpp"

@VladimirKulyk

This comment has been minimized.

Copy link

@VladimirKulyk VladimirKulyk commented Nov 5, 2017

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

//other imports
@mkyung

This comment has been minimized.

Copy link

@mkyung mkyung commented Nov 24, 2018

On 3.4.4 issue still exists,

In the .mm file I moved #import <opencv2/opencv.hpp> above #import <Foundation/Foundation.h> and it worked

@DongHeZheng

This comment has been minimized.

Copy link

@DongHeZheng DongHeZheng commented Jun 12, 2019

You can change opencv_modules.hpp like this.

#ifdef USE_OPENCV_STITCHING
#define HAVE_OPENCV_STITCHING
#endif

So, if you want to use stitching module, you can define USE_OPENCV_STITCHING, otherwise I can avoid such this compiling problem.
But, personally, I guess OpenCV teams have to change this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.