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

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

我试图在 visual studio + opencv 中编译一个简单的代码,但是出现了这个错误。

代码:

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

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

输出:

error LNK1104: cannot open file 'opencv_core300d.lib'
error MSB6006: "link.exe" exited code1104.

您可能添加了正确的包含目录,但您忘记了 link 实际的库。

Configuration Properties - Linker - General - Additional Library Directories 下你需要添加以下内容: $(OPENCV_DIR)\staticlib;

OPENCV_DIR 指向您的构建文件夹。 例如:E:\opencv\build\x86\vc12.

完成后,您还需要在 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

您只需要添加您需要的那些,但将它们全部添加也没有负面影响。那么,你确定你没有忘记任何东西。

在 opencv(vc14 和 vc15)中足以放置 opencv_world420d.lib(调试)和 opencv_world420.lib(发布)。很可能在代码的某处存在以前版本的遗留问题。此 opencv_core300d.lib 已包含在 opencv_world420d.lib.

中的核心库