error LNK2019: 無法解析的外部符號,解決辦法


最近在看一個程序,每次編譯時都會出現

chushihua.obj : error LNK2019: 無法解析的外部符號 "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow@cv@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV_InputArray@1@@Z),該符號在函數 "void __cdecl mouseEvent(int,int,int,int,void *)" (?mouseEvent@@YAXHHHHPAX@Z) 中被引用
1>chushihua.obj : error LNK2019: 無法解析的外部符號 "void __cdecl cv::destroyWindow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?destroyWindow@cv@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z),該符號在函數 "void __cdecl InitialVideo(class cv::Mat &,class cv::Rect_<int> &)" (?InitialVideo@@YAXAAVMat@cv@@AAV?$Rect_@H@2@@Z) 中被引用
1>chushihua.obj : error LNK2019: 無法解析的外部符號 "int __cdecl cv::waitKey(int)" (?waitKey@cv@@YAHH@Z),該符號在函數 "void __cdecl InitialVideo(class cv::Mat &,class cv::Rect_<int> &)" (?InitialVideo@@YAXAAVMat@cv@@AAV?$Rect_@H@2@@Z) 中被引用
1>chushihua.obj : error LNK2019: 無法解析的外部符號 "void __cdecl cv::setMouseCallback(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,void (__cdecl*)(int,int,int,int,void *),void *)" (?setMouseCallback@cv@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@P6AXHHHHPAX@Z1@Z),該符號在函數 "void __cdecl InitialVideo(class cv::Mat &,class cv::Rect_<int> &)" (?InitialVideo@@YAXAAVMat@cv@@AAV?$Rect_@H@2@@Z) 中被引用
1>chushihua.obj : error LNK2019: 無法解析的外部符號 "public: virtual __thiscall cv::VideoCapture::~VideoCapture(void)" (??1VideoCapture@cv@@UAE@XZ),該符號在函數 _main 中被引用
1>chushihua.obj : error LNK2019: 無法解析的外部符號 "public: virtual bool __thiscall cv::VideoCapture::isOpened(void)const " (?isOpened@VideoCapture@cv@@UBE_NXZ),該符號在函數 _main 中被引用
1>chushihua.obj : error LNK2019: 無法解析的外部符號 "public: __thiscall cv::VideoCapture::VideoCapture(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0VideoCapture@cv@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z),該符號在函數 _main 中被引用
1>D:\code\chushihua\Debug\chushihua.exe : fatal error LNK1120: 7 個無法解析的外部命令

通過在網上查資料,是缺少庫文件,我的編程環境是VS2008+OpenCV2.3,所以加上

#pragma comment( lib, "opencv_highgui231d.lib")
#pragma comment( lib, "opencv_core231d.lib")就可以了

一般遇到這種問題就是缺少庫文件,在頭文件后面加入#pragma comment( lib, "*****.lib")就OK


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM