c++cvisual-studioopencv

fatal error C1189: #error : core.hpp header must be compiled as C++


I am building a C application that uses OpenCV.

when compiling, I get the following error:

fatal error C1189: #error :  core.hpp header must be compiled as C++

I did not find how to resolve this error.

How to use OpenCV from a C project?


Solution

    1. Select the required file.
    2. Launch its properties window
    3. Goto C/C++ -> Advanced, and change Compile as to Compile as C++ Code (/TP)

    enter image description here