Search code examples
c++opencv3.1

OpenCV3.10 core.hpp must be compiled in C++


i have installed OpenCV 3.10 and the linked the opencv_world310.lib to release and opencv_world310d.lib to debug. Moreover I put the compiler options in search directory to ...opencv\build\include. I got a undefined reference error when i left out #include <opencv2/highgui.hpp. Now that i have included it my code looks like this:

#include <stdio.h>
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include <opencv2/highgui.hpp>


int main(void){

printf("HALLO!");


return 0;
}

When i try to build it core.hpp opens and the error: core.hpp must be compiled in C++ occurs. I am using the GNU GCC Compiler in Codeblocks. What should i do to solve the problem?


Solution

  • Check you compiler options. Open CV 3.10 C++ API requires code to be compiled as C++, but not C. You can use answer to "CodeBlocks: change project language c and c++" question to change the options.

    Also use the new Open CV 3.10 API

    #include <opencv2/opencv.hpp>` 
    

    instead of all the other Open CV header files. This header includes core functionality. To enable highgui module you need to define HAVE_OPENCV_HIGHGUI in your project settings.