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

23,805

Solution 1

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.

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

Share:
23,805
poke19962008
Author by

poke19962008

B.Tech sophomore in Computer Science and Engineering at SRM University. I am particularly interested in Algorithms, Data Structures, Data Science and Web Development and looking for any projects or avenues that can help me learn new things in these subjects. I am a keen learner and always up for a challenge.

Updated on July 09, 2022

Comments

  • poke19962008
    poke19962008 almost 2 years

    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.
    
  • Schütze
    Schütze over 6 years
    There is no folder called staticlib. Additionally, there is no vc12 but vc14 (under x64). So this answer is not really helping.