我正在将 OpenCV 2.4.10 与带有 MinGW 的 Eclipse C++ 一起使用。这个版本的 opencv 只有 visual C 的库,所以我在 MinGW (eclipse) 中链接了这些库。我尝试运行一个简单的代码来加载和显示图像:
#include<iostream>
#include<cv.h>
#include<highgui.h>
using namespace std;
using namespace cv;
int main(){
Mat image = imread("D:/photo1.tif",1);
namedWindow( "Display", WINDOW_AUTOSIZE );
imshow( "Display", image );
return 0;
}
但在构建时显示以下错误:
undefined reference to `cv::imread(std::string const&, int)'
undefined reference to `cv::namedWindow(std::string const&, int)'
undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
我也对 Tesseract OCR 引擎进行了同样的尝试,但它也显示了同样的问题,即对各种函数和类的 undefined reference 。我不知道我在链接或构建文件时是否遗漏了什么。所以请帮助。谢谢
最佳答案
IMO Ashot 的回答几乎是正确的,但我觉得你根本没有构建它们。如果是这样的话..
Build for MinGW , 这些库对所有代码都有不同的链接,你不能用不同的编译库进行编译
关于c++ - 使用opencv时未定义对各种函数的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27402059/