Mario
Mario

Reputation: 39

LNK2019: Unresolved External Symbol in OpenCV

I've been trying a few to days to configure the opencv library in Windows 10 and it's being quite a nightmare!

This is my code:

#include <opencv2/video.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
#include <svm.h>
#include <stdio.h>

using namespace std;
using namespace cv;

int main(int argc, char** argv) {

    (...)

    /*2. PROCESAR VÍDEO*/

    int c;
    IplImage* color_img;
    CvCapture* cv_cap = cvCaptureFromCAM(0);
    cvNamedWindow("Video", 0); // create window
    for (;;) {
        color_img = cvQueryFrame(cv_cap); // get frame
        if (color_img != 0)
            cvShowImage("Video", color_img); // show frame
        c = cvWaitKey(10); // wait 10 ms or for key stroke
        if (c == 27)
            break; // if ESC, break and quit
    }
    /* clean up */

    cvReleaseCapture(&cv_cap);
    cvDestroyWindow("Video");
    return (EXIT_SUCCESS);
}

This is my Visual Studio 17 configuration:

C/C++

-In Linker:

linker image

In Linker/Input i've added the following libs:

Also: - I have opencv 3.4.5 version - running in x64 - I've built the library with cmake and VisualStudio17, after several tries with MINGW32, cygwin and Netbeans.

No error is showed in the IDE but when compiling shows the famous error "LNK2019 unresolved external symbol". I've tried with the recommendations of all the other posts with this topic but couldn't find the solution.

ERROR Image

Error LNK2019 símbolo externo "class cv::Mat __cdecl cv::imread(class cv::String const &,int)" (?imread@cv@@YA?AVMat@1@AEBVString@1@H@Z) sin resolver al que se hace referencia en la función main Project1 C:\Users\Mario I\source\repos\Project1\Project1\Main.obj 1

Error LNK2019 símbolo externo cvCreateCameraCapture sin resolver al que se hace referencia en la función main Project1 C:\Users\Mario I\source\repos\Project1\Project1\Main.obj 1

Error LNK2019 símbolo externo cvQueryFrame sin resolver al que se hace referencia en la función main Project1 C:\Users\Mario I\source\repos\Project1\Project1\Main.obj 1

Error LNK2019 símbolo externo cvReleaseCapture sin resolver al que se hace referencia en la función main Project1 C:\Users\Mario I\source\repos\Project1\Project1\Main.obj 1

Error LNK1120 4 externos sin resolver Project1 C:\Users\Mario I\source\repos\Project1\x64\Debug\Project1.exe 1

Upvotes: 0

Views: 4034

Answers (1)

Baj Mile
Baj Mile

Reputation: 780

I am using the latest prebuild OpenCV 4.0 libraries with Windows 10, x64, and Visual Studio 2015. I setup it with using environment var:

  1. setx -m OPENCV_DIR D:\Vision\opencv\build\x64\vc14
  2. check it with - echo %OPENCV_DIR%
  3. for VS2015 Debug, Platform x64, enter the following Project settings:

Additional Include Paths: $(OPENCV_DIR)....\include

Additional Library Directories: %OPENCV_DIR%\lib

Additional Dependencies: opencv_world400d.lib;

  1. for VS Release

Additional Dependencies: opencv_world400.lib;

Be careful Platform to be set to x64.

Also see: https://docs.opencv.org/3.0-rc1/d3/d52/tutorial_windows_install.html#tutorial_windows_install_path

Upvotes: 3

Related Questions