c++ - OpenCV3.10 core.hpp必须用C++编译

标签 c++ opencv3.1

我已经安装了 OpenCV 3.10 并链接了 opencv_world310.libreleaseopencv_world310d.lib调试。 此外,我将编译器选项放在搜索目录中 ...opencv\build\include .当我遗漏 #include <opencv2/highgui.hpp 时出现 undefined reference 错误.现在我已经包含了它,我的代码如下所示:

#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++发生。 我在 Codeblocks 中使用 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 头文件。此 header 包括核心功能。要启用 highgui 模块,您需要在项目设置中定义 HAVE_OPENCV_HIGHGUI

关于c++ - OpenCV3.10 core.hpp必须用C++编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39586623/

相关文章:

android - 有没有办法使用同一个库的两个不同版本,所以android中的文件

c++ - 在类中定义时,mysql C 连接器函数不起作用

c++ - 为什么这种继承失败(使用父类(super class)的方法)C++

c++ - 在 OpenGL/CUDA 中将顶点数据传输到 GPU 的最快方法

c++ - RenderTexture 创建的图像不可见

c++ - 适当提取 vector 内的对象类型,然后在比较中使用。由 小码哥发布于

python - 傅立叶变换 opencv python FFT & DFT

python-3.x - 调用 cv2.findContours() 时出现 "ValueError: not enough values to unpack"

python - 如何在CV2中的图像上使用orb?

python - 在python中使用opencv流式传输的视频的异步列表