Home>
History

I am running Visual Studio 2019 on Windows10. As a project, I have selected "Windows Desktop Application" that can create an application with a graphical user interface that runs on Windows, but I cannot use OpenCV well.

About OpenCV settings

https://opencv.org/releases/
Download the Windows file from here and unzip it
C: \ hoge \ opencv \
It is put in. For example, opencv.hpp is
C: \ hoge \ opencv \ build \ include \ opencv2 \ opencv.hpp
It is in. Also, in the Windows10 path
C: \ hoge \ opencv \ build \ x64 \ vc15 \ bin
Has been added.

About Visual Studio settings

Visual Studio 2019 is installed as standard.
A project called WinPro is created in C: \ hoge \.
When you build, a file called C: \ hoge \ WinPro \ Debug \ WinPro.exe is created.

To use OpenCV, include it in the include path of Visual Studio
C: \ hoge \ opencv \ build \ include \
Has been added.
Also, the Visual Studio library path includes
C: \ hoge \ opencv \ build \ x64 \ vc15 \ lib
Has been added.

Current situation

From line 4 to line 6 of WinPro.cpp

#include "framework.h"
#include "WinPro.h"
#include "opencv2/opencv.hpp" // add this line


I was able to build successfully.

Error details

I want to display an image file called C: \ hoge \ WinPro \ picture.png in the main window. So, in lines 29-30 of WinPro.cpp,

// TODO: Insert the code here.
cv :: Mat img;// add this line
1>------ Start build: Project: WinPro, Configuration: Debug x64 ------
1>WinPro.cpp
1>WinPro.obj: error LNK2019: Unresolved external symbol "void __cdecl cv :: fastFree (void *)" (? FastFree @ cv @@ YAXPEAX @ Z) is function "public: __cdecl cv :: Mat :: ~ Mat (void) "(?? 1Mat @ cv @@ QEAA @ XZ)
1>WinPro.obj: error LNK2019: Unresolved external symbol "public: void __cdecl cv :: Mat :: deallocate (void)" (? Deallocate @ Mat @ cv @@ QEAAXXZ) is a function "public: void __cdecl cv: : Mat :: release (void) "(? Release @ Mat @ cv @@ QEAAXXZ)
1>C: \ hoge \ WinPro \ x64 \ Debug \ WinPro.exe: fatal error LNK1120: 2 unresolved external references
1>Build of project "WinPro.vcxproj" finished-failed.
========== Build: 0 successful, 1 failed, 0 no update required, 0 skipped ==========

is displayed and building is not possible.

  • Answer # 1

      

    1>C: \ hoge \ WinPro \ x64 \ Debug \ WinPro.exe: fatal error LNK1120: 2 unresolved external references

    It's a link error when building Visual Studio 2019. If you continue to use OpenCV, it is better to review and set up the environment settings for the build once. In this StackOverflow, similar questions have been posted several times in the past. If you search for "Windows OpenCV" in "Search by keyword", you may get something useful.

    Linker settings when using opencv in VS2019-StackOverflow # 215829

    A little older than 2015
    OpenCV] I want to use OpenCV in C language on Windows-StackOverflow # 14459

    There are articles compiled by @IT outside StackOverflow.
    3rd OpenCV environment construction (OpenCV 3.0/3.1) (1/3)[email protected] OpenCV introduction [3.0 support]