opencv 3.0.0 linker error when instantiating Mat object

1.8k views Asked by At

i'm trying to compile a simple opencv program. I've set the environment variables and also set the c++ additional include dir of the project as well as the additional linker directory and input dependencies (opencv_ts300d.lib and opencv_world300d.lib) but i keep getting linker's error for this code :

    #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;
}

the errors are the following :

Translated:

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

Original:

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

2

There are 2 answers

0
Daniel On BEST ANSWER

When this happened for me, I was linking to the x64 versions of of the OpenCV library but attempting to compile into a x86 (Win32) application. Just changing from a 32 bit to 64 bit application made mine work.

0
JoeCodeCreations On

Try

#include <"highgui.hpp">

I'm not at my work computer to check my source but I believe it is something like this.