4

I'm trying to compile a simple code in visual studio + opencv, but got this error.

Code:

#include <cstdio.h>
#include <opencv2\opencv.hpp>

void main(){  
   std::cout<<CV_VERSION;
}

Output:

error LNK1104: cannot open file 'opencv_core300d.lib'
error MSB6006: "link.exe" exited code1104.
poke19962008
  • 714
  • 1
  • 9
  • 13
  • 1
    You are not linking opencv_core... Look [here](http://stackoverflow.com/a/31545237/5008845) and follow the steps! – Miki Aug 09 '15 at 17:27

2 Answers2

4

You probably added the correct include directories, but you forgot to link the actual libraries.

Under Configuration Properties - Linker - General - Additional Library Directories you need to add the following: $(OPENCV_DIR)\staticlib;

With OPENCV_DIR pointing to your build folder. For example: E:\opencv\build\x86\vc12.

After you've done that, you also need to add the lines below here under Configuration Properties - Linker - Input - Additional Dependencies

IlmImfd.lib
libjasperd.lib
libpngd.lib
libjpegd.lib
libtiffd.lib
libwebpd.lib
opencv_calib3d300d.lib
opencv_core300d.lib
opencv_features2d300d.lib
opencv_flann300d.lib
opencv_hal300d.lib
opencv_highgui300d.lib
opencv_imgcodecs300d.lib
opencv_imgproc300d.lib
opencv_ml300d.lib
opencv_objdetect300d.lib
opencv_photo300d.lib
opencv_shape300d.lib
opencv_stitching300d.lib
opencv_superres300d.lib
opencv_ts300d.lib
opencv_video300d.lib
opencv_videoio300d.lib
opencv_videostab300d.lib
zlibd.lib
ippicvmt.lib
comctl32.lib
vfw32.lib

You only need to add the ones you need, but there's no negative side at adding them all. Then, you're sure you didn't forget anything.

Kate Orlova
  • 3,225
  • 5
  • 11
  • 35
Jeroen Vervaeke
  • 1,040
  • 9
  • 20
  • There is no folder called `staticlib`. Additionally, there is no `vc12` but `vc14` (under x64). So this answer is not really helping. – Schütze Dec 19 '17 at 13:15
2

In opencv (vc14 and vc15) its enough to put opencv_world420d.lib (in debug) and opencv_world420.lib (in release). Most probably somewhere in the code there are leftovers from previous versions. This opencv_core300d.lib is included core libraries which is already inside opencv_world420d.lib.

DeepML
  • 23
  • 6