Getting LINK2001 error in MSVS2017 although I have added both lib files to dependencies
I'm getting this error in MSVS2017:
1>------ Build started: Project: OpenCLTest, Configuration: Release x64 ------
1>OpenCLTest.obj : error LNK2001: unresolved external symbol "int __cdecl cv::_interlockedExchangeAdd(int *,int)" (?_interlockedExchangeAdd@cv@@YAHPEAHH@Z)
1>c:\users\chubak\documents\visual studio 2017\Projects\OpenCLTest\x64\Release\OpenCLTest.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "OpenCLTest.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
For this code:
#include "stdafx.h"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat image = imread("C:\\Users\\Chubak\\Pictures\\index.jpg");
if (image.empty())
return -1;
imshow("TEST", image);
waitKey();
return 0;
}
Although I have added:
C:\opencv\build\x64\vc15\lib\opencv_world400.lib
C:\opencv\build\x64\vc15\lib\opencv_world400d.lib
To the dependencies. Why?
Edit: I just found out there are prebuilt libraries in NuGet, so I downloaded them:
C:\Users\Chubak\Documents\Visual Studio 2017\Projects\OpenCLTest\packages\OpenCV.Win.Core.310.6.1\build\native\win10-x64\opencv_core310.lib
C:\Users\Chubak\Documents\Visual Studio 2017\Projects\OpenCLTest\packages\OpenCV.Win.ImgCodecs.310.6.1\build\native\win10-x64\opencv_imgcodecs310.lib
C:\Users\Chubak\Documents\Visual Studio 2017\Projects\OpenCLTest\packages\OpenCV.Win.ImgProc.310.6.1\build\native\win10-x64\opencv_imgproc310.lib
C:\Users\Chubak\Documents\Visual Studio 2017\Projects\OpenCLTest\packages\OpenCV.Win.HighGUI.310.6.1\build\native\win10-x64\opencv_highgui310.lib
C:\Users\Chubak\Documents\Visual Studio 2017\Projects\OpenCLTest\packages\OpenCV.Win.Calib3D.310.6.1\build\native\win10-x64\opencv_calib3d310.lib
C:\Users\Chubak\Documents\Visual Studio 2017\Projects\OpenCLTest\packages\OpenCV.Win.Features2D.310.6.1\build\native\win10-x64\opencv_features2d310.lib
C:\Users\Chubak\Documents\Visual Studio 2017\Projects\OpenCLTest\packages\OpenCV.Win.FLANN.310.6.1\build\native\win10-x64\opencv_flann310.lib
C:\Users\Chubak\Documents\Visual Studio 2017\Projects\OpenCLTest\packages\OpenCV.Win.ML.310.6.1\build\native\win10-x64\opencv_ml310.lib
C:\Users\Chubak\Documents\Visual Studio 2017\Projects\OpenCLTest\packages\OpenCV.Win.Video.310.6.1\build\native\win10-x64\opencv_video310.lib
C:\Users\Chubak\Documents\Visual Studio 2017\Projects\OpenCLTest\packages\OpenCV.Win.VideoIO.310.6.1\build\native\win10-x64\opencv_videoio310.lib
But I still get three, exactly three unresolved externals errors:
1>------ Build started: Project: OpenCLTest, Configuration: Release x64 ------
1>OpenCLTest.obj : error LNK2001: unresolved external symbol "int __cdecl cv::_interlockedExchangeAdd(int *,int)" (?_interlockedExchangeAdd@cv@@YAHPEAHH@Z)
1>OpenCLTest.obj : error LNK2001: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?imread@cv@@YA?AVMat@1@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
1>OpenCLTest.obj : error LNK2001: unresolved external symbol "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow@cv@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV_InputArray@1@@Z)
1>c:\users\chubak\documents\visual studio 2017\Projects\OpenCLTest\x64\Release\OpenCLTest.exe ...