OpenCV错误:“链接:致命错误LNK1104:无法打开文件'opencv_core300d.lib'”

问题描述 投票:3回答:1

我正在尝试在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.
c++ visual-studio opencv visual-studio-2013 opencv3.0
1个回答
3
投票
您可能添加了正确的包含目录,但是忘记了链接实际的库。

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

您只需要添加所需的内容,但是添加全部内容没有消极的一面。然后,您确定您不会忘记任何事情。
© www.soinside.com 2019 - 2024. All rights reserved.