LNK2019: unresolved external symbol error in Visual Studio C++

First check How to build applications with OpenCV inside the Microsoft Visual Studio

If you still suffer from the same problem, you could be under one of the below cases.

  1. Your active solution platform is x86 but you are trying to link x64 OpenCV libraries.
  2. Your active solution platform is X64 but you are trying to link x86 OpenCV libraries.

If you are under one of these cases, check Compiling a 64-bit Application in Microsoft Visual Studio Express 2010


Add these into your code:

#pragma comment (lib, "opencv_core248d.lib")
#pragma comment (lib, "opencv_highgui248d.lib")
#pragma comment (lib, "opencv_imgproc248d.lib")
#pragma comment (lib, "opencv_video248d.lib")
#pragma comment (lib, "opencv_features2d248d.lib")

It worked for me.


'unresolved external symbol' means that you're not linking with required library. Go to Properties -> Linker -> Additional Library dependencies and add path to OpenCV libs.