我试图在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.
答案 0 :(得分:3)
您可能添加了正确的include目录,但是您忘记链接实际的库。
在Common Properties
- Linker
- General
- Additional Library Directories
下,您需要添加以下内容:
$(OPENCV_DIR)\staticlib;
OPENCV_DIR
指向您的构建文件夹。
例如:E:\opencv\build\x86\vc12
。
完成上述操作后,您还需要在Common 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
你只需要添加你需要的那些,但是添加它们并没有消极的一面。然后,你确定你没有忘记任何事情。
答案 1 :(得分:1)
在opencv(vc14和vc15)中,足以放入opencv_world420d.lib(在调试中)和opencv_world420.lib(在发行中)。很有可能在代码中的某个地方存在以前版本的遗留物。这个opencv_core300d.lib包含在opencv_world420d.lib中已经包含的核心库。