0

I seem to have an error with the linking part even though my code compiled with no errors.

I set the property like this: I set the property like this - linked image

I also added files required in the Linker -> General -> Additional library directories and Linker -> Input -> Additional Dependencies

It still gave me an error after that.

code:

#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;

(output) error line:

Severity Code Description Project File Line Suppression State
Error LNK1104 cannot open file 'IlmImfd.lib'    opencvTry

(output) when I try to redo the project with the same codes with the lib files included:

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   
4

1 回答 1

1

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

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

您只需要添加您需要的那些,但将它们全部添加没有负面影响。然后,您确定您没有忘记任何事情。

于 2017-07-21T03:23:36.517 回答