我在 Win8、最新的 MinGW 和 Eclipse Kepler R1、CDT 上开始了 opencv 2.4.7 的教程。 C++ 编译器包含引用 [path-to-opencv]\open247\build\include。
在 MinGW C++ 链接器中,我添加了库路径 [path-to-opencv]\open247\build\x64\vc11\lib。 vc11 目录包含我读过的 VisualStudio 库。用 MinGW 编译它们还可以吗?
我为这个示例添加了核心和 highgui 库(我认为我们需要的不只是那些)。
但是,对于下面这个简单的空闲代码,我引发了以下编译错误。
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
int main(){
Mat image;
}
编译错误是:
Description Resource Path Location Type
undefined reference to `cv::fastFree(void*)' FirstOpenCV line 278, external location: C:\Users\John\Documents\Software\opencv247\build\include\opencv2\core\mat.hpp C/C++ Problem
这是什么原因?
如果我添加
namedWindow("testWindow", 1);
我什至遇到这个错误
Description Resource Path Location Type
undefined reference to `cv::namedWindow(std::string const&, int)' main.cpp /FirstOpenCV/src line 23 C/C++ Problem
最佳答案
您是否正确链接了您的库?
-lopencv_core
-lopencv_highgui
-L<opencv_library_path>
必须在编译器/链接器命令行上的源文件之后指定库。 (链接器跟踪未解析的符号,并通过稍后的命令行参数解析它们。)
关于c++ - 键入对 `cv::fastFree(void*)' 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20483476/