LNK2019 Error When Building Version 3.1.0

asked 2018-04-05 12:59:33 -0500

rob-evans gravatar image

updated 2018-04-05 13:04:44 -0500

berak gravatar image

First of all, I am a noob to both C++ and OpenCV, but I am not a noob to Visual Studio.

When trying to build a simple application (see below), I get LNK2019 errors beginning with complaints about the Mat class.

Mine is a simple console app. I installed OpenCVdefault v3.1.0 via NuGet. A dependency package called opencvdefault.redist was automatically installed in the process. I am using VS2017 with the Platform Toolset set to Visual Studio 2013 (v120). I tried setting the toolset to VS 2017 but got the same errors. In my project property pages, the Platform is set to x64.

I don't think it is material to the error condition, but prior to installing OpenCVdefault v3.1.0 via NuGet, I thought I might try compiling OpenCV. So I downloaded it, into a separate folder, of course, and set my environment variables with "setx -m OPENCV_DIR D:\OpenCV\Build\x64\vc12".

Please excuse the formatting below. I haven't gotten the hang of it yet.

#include "stdafx.h"
#include <opencv2/opencv.hpp>

using namespace cv;

int main()
{
    // Read the image file 
    Mat image = imread("D:/My OpenCV Website/Eagle.jpg");
    return 0;
}
edit retag flag offensive close merge delete

Comments

  • 3.1.0: outdated
  • nuget: unfortunately not really supported from opencv (they do not maintain anything there)
  • Visual Studio 2013: ouch
  • "setx -m OPENCV_DIR D:\OpenCV\Build\x64\vc12" --check, if that even exists.

sidenote: what's the silly #include "stdafx.h" doing there ? do you know what you're doing at all ?

berak gravatar imageberak ( 2018-04-05 13:04:09 -0500 )edit

if you're already using VS2017, could you try with the official current release instead ?

berak gravatar imageberak ( 2018-04-05 13:24:30 -0500 )edit

berak said, "do you know what you're doing at all ?"
Well, berak, you do know what "noob" means, right?

rob-evans gravatar imagerob-evans ( 2018-04-05 14:09:22 -0500 )edit
  • And, berak said, "if you're already using VS2017, could you try with the official current release instead ?" I hope to build a plug-in for Adobe Acrobat DC which requires C++ code compiled with VS2013. The official current release won't work for me in this case. OpenCV v3.1.0 is the most recent version that I could find that is compatible with V12. I have Visual Studio 2017. Hence, my Platform Toolset is set to Visual Studio 2013 (v120).

  • "setx -m OPENCV_DIR D:\OpenCV\Build\x64\vc12" --check, if that even exists." Yep. It does in deed exist.

rob-evans gravatar imagerob-evans ( 2018-04-05 14:29:15 -0500 )edit