即使我的代码编译没有错误,我似乎也有链接部分的错误。
我像这样设置属性:
我还添加了所需的文件
Linker -> General -> Additional library directories
和
Linker -> Input -> Additional Dependencies
之后它仍然给我一个错误。
代码:
#include "opencv2/core.hpp"
#include "C:/Users/Downloads/opencv_contrib-master/opencv_contrib-master/modules/face/include/opencv2/face.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/objdetect.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
using namespace cv;
using namespace cv::face;
using namespace std;
(输出)错误行:
Severity Code Description Project File Line Suppression State
Error LNK1104 cannot open file 'IlmImfd.lib' opencvTry
(输出)当我尝试使用包含lib文件的相同代码重做项目时:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: static struct
cv::Ptr<class cv::face::FisherFaceRecognizer> __cdecl
cv::face::FisherFaceRecognizer::create(int,double)" (
create@FisherFaceRecognizer@face@cv@@SA?AU?
$Ptr@VFisherFaceRecognizer@face@cv@@@3@HN@Z) referenced in function main
opencvTry C:\Users\151554F\Documents\Visual Studio 2017\Projects\In
progress\Face recog\opencvTry\try.obj 1
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: int __cdecl
cv::face::FaceRecognizer::predict(class cv::_InputArray const &)const " (?
predict@FaceRecognizer@face@cv@@QEBAHAEBV_InputArray@3@@Z) referenced in
function main opencvTry C:\Users\151554F\Documents\Visual Studio
2017\Projects\In progress\Face recog\opencvTry\try.obj 1
答案 0 :(得分:1)
您可能添加了正确的include目录,但是您忘记链接实际的库。
在Configuration 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
你只需要添加你需要的那些,但是添加它们并没有消极的一面。然后,你确定你没有忘记任何事情。