c++visual-studioopencvvisual-studio-2013opencv3.0

OpenCV error: “LINK : fatal error LNK1104: cannot open file 'opencv_core300d.lib' ”


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.

Solution

  • 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.