我正在尝试编译一个简单的 opencv 程序。我已经设置了环境变量,还设置了项目的 C++ 附加包含目录以及 额外的链接器目录和输入依赖项(opencv_ts300d.lib 和 opencv_world300d.lib)但我一直收到此代码的链接器错误:
#include<iostream>
#include<opencv2\opencv.hpp>
#include<cstdio>
#include <string>
#include <opencv2\core\core.hpp>
#include <opencv2\imgcodecs.hpp>
#include <opencv2\highgui\highgui.hpp>
using namespace std;
using namespace cv;
int main(int argc, char** argv)
{
cv::Mat a;
return 0;
}
错误如下:
翻译:
Error 1 error LNK2019: unresolved external symbol "void __cdecl >cv::fastFree(void *)" (?fastFree@cv@@YAXPAX@Z) referenced in function "public: >__thiscall cv::Mat::~Mat(void)" (??1Mat@cv@@QAE@XZ) C:\Users\Sergio\documents\visual studio 2013\Projects\opencvtest\opencvtest\Origine.obj opencvtest
Error 2 error LNK2019: unresolved external symbol "public: void >__thiscall cv::Mat::deallocate(void)" (?deallocate@Mat@cv@@QAEXXZ) referenced >in function "public: void __thiscall cv::Mat::release(void)" (?>release@Mat@cv@@QAEXXZ) C:\Users\Sergio\documents\visual studio 2013\Projects\opencvtest\opencvtest\Origine.obj opencvtest
原文:
Errore 1 error LNK2019: riferimento al simbolo esterno "void __cdecl cv::fastFree(void *)" (?fastFree@cv@@YAXPAX@Z) non risolto nella funzione "public: __thiscall cv::Mat::~Mat(void)" (??1Mat@cv@@QAE@XZ) C:\Users\Sergio\documents\visual studio 2013\Projects\opencvtest\opencvtest\Origine.obj opencvtest
Errore 2 error LNK2019: riferimento al simbolo esterno "public: void __thiscall cv::Mat::deallocate(void)" (?deallocate@Mat@cv@@QAEXXZ) non risolto nella funzione "public: void __thiscall cv::Mat::release(void)" (?release@Mat@cv@@QAEXXZ) C:\Users\Sergio\documents\visual studio 2013\Projects\opencvtest\opencvtest\Origine.obj opencvtest
最佳答案
当我遇到这种情况时,我正在链接到 OpenCV 库的 x64 版本,但试图编译成 x86 (Win32) 应用程序。只是从 32 bit to 64 bit application 改变让我的工作成功。
关于c++ - 实例化 Mat 对象时 opencv 3.0.0 链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30831488/