OpenCV3.10 core.hpp必须在c++中编译

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

本文关键字:c++ 编译 core hpp OpenCV3      更新时间:2023-10-16

我已经安装了OpenCV 3.10,并将opencv_world310.lib链接到releaseopencv_world310d.lib进行调试。此外,我把编译器选项在搜索目录...opencvbuildinclude。当我离开#include <opencv2/highgui.hpp时,我得到了一个未定义的引用错误。现在我已经包含了它,我的代码看起来像这样:

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

int main(void){
printf("HALLO!");

return 0;
}

当我试图构建它core.hpp打开和error: core.hpp must be compiled in C++发生。我在代码块中使用GNU GCC编译器。我该怎么做才能解决这个问题?

检查编译器选项。Open CV 3.10 c++ API要求将代码编译为c++,而不是C。您可以使用"CodeBlocks: change project language C and c++"问题的答案来更改选项。

也可以使用新的Open CV 3.10 API

#include <opencv2/opencv.hpp>` 

而不是所有其他Open CV头文件。这个头包含核心功能。要启用highgui模块,需要在项目设置中定义HAVE_OPENCV_HIGHGUI