0

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:

  • In C/C++

C/C++

-In Linker:

linker image

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

  • opencv_calib3d345d.lib opencv_core345d.lib opencv_features2d345d.lib opencv_flann345d.lib opencv_highgui345d.lib opencv_imgproc345d.lib libpng.lib libtiff.lib zlib.lib IlmImf.lib libjasper.lib libjpeg-turbo.lib opencv_ml345d.lib opencv_objdetect345d.lib opencv_photo345d.lib opencv_stitching345d.lib opencv_superres345d.lib opencv_video345d.lib opencv_videostab345d.lib

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

drescherjm
  • 10,365
  • 5
  • 44
  • 64
Mario
  • 39
  • 1
  • 3
  • Please add the exact text of the error message. In Visual Studio its best to copy that from the Output Tab. You can use `Alt+2` to get to the Output Tab. – drescherjm Dec 30 '18 at 17:58
  • I know its a bit old, but [the process is pretty easy to follow....](https://dogfeatherdesign.com/opencv-3-0-microsoft-visual-studio-2015-cmake-and-c/) – zipzit Dec 30 '18 at 17:58
  • Thank you @drescherjm. Just added an image (sorry it's in spanish) – Mario Dec 30 '18 at 18:01
  • ***Just added an image*** At StackOverflow actual text is preferred over pictures of text. – drescherjm Dec 30 '18 at 18:02
  • Are you sure you applied the linker setting to the Debug configuration? – drescherjm Dec 30 '18 at 18:04
  • @drescherjm I added to the Linker settings the path where the libraries are. Maybe I'm forgetting something? – Mario Dec 30 '18 at 18:08
  • @Mario Did you add the libraries themselves? You need the paths and the names of the libraries. – john Dec 30 '18 at 18:21
  • Hi @john I'm not sure what do you mean by adding the libraries themselves? – Mario Dec 30 '18 at 18:38
  • if I see it right you ate missing some lib(s), have a look sth. like opencv_codecs or similar – Micka Dec 30 '18 at 19:28
  • 1
    you'll need opencv_imgcodecs345d.lib here are some more modules, you might want to use videoio, too, maybe: https://docs.opencv.org/3.3.1/index.html – Micka Dec 30 '18 at 21:27
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Ulrich Eckhardt Dec 31 '18 at 08:05
  • @Mario In the Project Properties under Linker/Input/Additional Dependencies you have to add the names of the libraries you want to link with. It's not enough to add the paths containing the libraries, the libraries themselves must also be specified. Which is obvious if you think about it, so apologies if I'm telling you something you already know. – john Dec 31 '18 at 09:35
  • Thank you @Micka. Just added but no improvement... – Mario Dec 31 '18 at 11:19
  • Thanks @john. Yes. This was already done. – Mario Dec 31 '18 at 11:20
  • @zipzit It's a really good guide! What a pity to found it now, that would've save me so much time hahaha. I read it to se if there was some difference with me but couldn't find any... – Mario Dec 31 '18 at 11:23
  • is there the same unresolved symbol about imread, or something else now? – Micka Dec 31 '18 at 15:20

1 Answers1

2

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

Baj Mile
  • 750
  • 1
  • 8
  • 17
  • That worked!!! I erased the 3.4.5 version, and created a new project following your steps (erasing the previous line in System Path). (Only I had to change to the actual Path in step 1 and also to write the complete path in "Additional Include Paths"). Finally! thank youuuuu – Mario Jan 02 '19 at 18:03