Xcode 7 and openCV (no Swift): Core.hpp header must be compiled as C++

后端 未结 4 1748
Happy的楠姐
Happy的楠姐 2021-02-07 09:42

I have followed the instructions on how to install OpenCV on an iOS project. However when using Xcode 7 I had to add manually a prefix header. Doing this unfortunately did not h

4条回答
  •  耶瑟儿~
    2021-02-07 10:10

    OpenCV is a C++ framework, which means that any code that makes use of OpenCV has to be compiled with C++ interpretation, rather than C interpretation.

    The errors you see, e.g. with the using namespace cv; indicate that the code is compiled using the objective-C compiler, rather than the objective-C++ compiler.

    As I mentioned in my comment the easiest way to get this to happen is to ensure that any file that #includes an opencv header must be named e.g. ViewController.mm, i.e. it must be an Objective-C++ file.

    Alternatively, you can select and override the Type of the file, by explicitly selecting the Objective-C++ Source option for the file type in the utilities pane.

提交回复
热议问题