error LNK2019: unresolved external symbol 问题

main.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CvSVM::~CvSVM(void)" (??1CvSVM@@UAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey@cv@@YAHH@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "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) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "bool __cdecl cv::imwrite(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &,class std::vector<int,class std::allocator<int> > const &)" (?imwrite@cv@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV_InputArray@1@ABV?$vector@HV?$allocator@H@std@@@3@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::_InputArray::_InputArray(class cv::Mat const &)" (??0_InputArray@cv@@QAE@ABVMat@1@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: virtual float const * __thiscall CvSVM::get_support_vector(int)const " (?get_support_vector@CvSVM@@UBEPBMH@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: virtual int __thiscall CvSVM::get_support_vector_count(void)const " (?get_support_vector_count@CvSVM@@UBEHXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl cv::circle(class cv::Mat &,class cv::Point_<int>,int,class cv::Scalar_<double> const &,int,int,int)" (?circle@cv@@YAXAAVMat@1@V?$Point_@H@1@HABV?$Scalar_@N@1@HHH@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: virtual float __thiscall CvSVM::predict(class cv::Mat const &,bool)const " (?predict@CvSVM@@UBEMABVMat@cv@@_N@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: virtual bool __thiscall CvSVM::train(class cv::Mat const &,class cv::Mat const &,class cv::Mat const &,class cv::Mat const &,struct CvSVMParams)" (?train@CvSVM@@UAE_NABVMat@cv@@000UCvSVMParams@@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall CvSVM::CvSVM(void)" (??0CvSVM@@QAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall CvSVMParams::CvSVMParams(void)" (??0CvSVMParams@@QAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: static class cv::MatExpr __cdecl cv::Mat::zeros(int,int,int)" (?zeros@Mat@cv@@SA?AVMatExpr@2@HHH@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall cv::Mat::copySize(class cv::Mat const &)" (?copySize@Mat@cv@@QAEXABV12@@Z) referenced in function "public: __thiscall cv::Mat::Mat(class cv::Mat const &)" (??0Mat@cv@@QAE@ABV01@@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall cv::Exception::~Exception(void)" (??1Exception@cv@@UAE@XZ) referenced in function "public: __thiscall cv::Mat::Mat(int,int,int,void *,unsigned int)" (??0Mat@cv@@QAE@HHHPAXI@Z)
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl cv::error(class cv::Exception const &)" (?error@cv@@YAXABVException@1@@Z) referenced in function "public: __thiscall cv::Mat::Mat(int,int,int,void *,unsigned int)" (??0Mat@cv@@QAE@HHHPAXI@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::Exception::Exception(int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (??0Exception@cv@@QAE@HABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@00H@Z) referenced in function "public: __thiscall cv::Mat::Mat(int,int,int,void *,unsigned int)" (??0Mat@cv@@QAE@HHHPAXI@Z)
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl cv::fastFree(void *)" (?fastFree@cv@@YAXPAX@Z) referenced in function "public: __thiscall cv::Mat::~Mat(void)" (??1Mat@cv@@QAE@XZ)
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall cv::Mat::deallocate(void)" (?deallocate@Mat@cv@@QAEXXZ) referenced in function "public: void __thiscall cv::Mat::release(void)" (?release@Mat@cv@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall cv::Mat::create(int,int const *,int)" (?create@Mat@cv@@QAEXHPBHH@Z) referenced in function "public: void __thiscall cv::Mat::create(int,int,int)" (?create@Mat@cv@@QAEXHHH@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall cv::MatConstIterator::seek(int,bool)" (?seek@MatConstIterator@cv@@QAEXH_N@Z) referenced in function "public: class cv::MatConstIterator & __thiscall cv::MatConstIterator::operator++(void)" (??EMatConstIterator@cv@@QAEAAV01@XZ)
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall cv::Mat::convertTo(class cv::_OutputArray const &,int,double,double)const " (?convertTo@Mat@cv@@QBEXABV_OutputArray@2@HNN@Z) referenced in function "public: class cv::Mat_<float> & __thiscall cv::Mat_<float>::operator=(class cv::Mat const &)" (??4?$Mat_@M@cv@@QAEAAV01@ABVMat@1@@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::_OutputArray::_OutputArray(class cv::Mat &)" (??0_OutputArray@cv@@QAE@AAVMat@1@@Z) referenced in function "public: class cv::Mat_<float> & __thiscall cv::Mat_<float>::operator=(class cv::Mat const &)" (??4?$Mat_@M@cv@@QAEAAV01@ABVMat@1@@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: class cv::Mat __thiscall cv::Mat::reshape(int,int,int const *)const " (?reshape@Mat@cv@@QBE?AV12@HHPBH@Z) referenced in function "public: class cv::Mat_<float> & __thiscall cv::Mat_<float>::operator=(class cv::Mat const &)" (??4?$Mat_@M@cv@@QAEAAV01@ABVMat@1@@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall cv::MatConstIterator::seek(int const *,bool)" (?seek@MatConstIterator@cv@@QAEXPBH_N@Z) referenced in function "public: __thiscall cv::MatConstIterator::MatConstIterator(class cv::Mat const *)" (??0MatConstIterator@cv@@QAE@PBVMat@1@@Z)
1>F:\MyProject\SVM\OpenCV\SVMexample\Debug\SVMexample.exe : fatal error LNK1120: 25 unresolved externals

原来在在Link里没有把以下的库包含进去。

opencv_core220d.lib
opencv_highgui220d.lib
opencv_video220d.lib
opencv_ml220d.lib
opencv_legacy220d.lib
opencv_imgproc220d.lib

### 回答1: error lnk2001: unresolved external symbol _getpriority 是一个与函数 getpriority 相关的链接错误。该错误表示在链接器阶段无法找到 getpriority 函数的定义。 getpriority 函数是用于获取进程或进程组的优先级的一个标准函数,该函数声明在头文件 #include <sys/resource.h> 中。然而,由于某些原因,链接器无法找到该函数的定义,导致出现 unresolved external symbol 错误。 要解决此问题,可以按照以下步骤操作: 1. 确保在源代码中正确地包含了 <sys/resource.h> 头文件。在 C/C++ 源文件的开头添加 #include <sys/resource.h>,以确保查找到正确的函数声明。 2. 检查编译器选项是否正确设置。有时,编译器选项可能需要手动指定以链接相应的库。对于 getpriority 函数,可能需要链接 librt 或 libpthread 库。可以尝试添加 -lrt 或 -lpthread 到编译器的选项中。 3. 确保链接器能够找到 getpriority 函数的实现。实现该函数的库文件应该与编译器链接,以便在链接器阶段解决外部符号引用。这通常涉及到正确设置库文件的路径或将库文件添加到链接器的库路径中。 总结:error lnk2001: unresolved external symbol _getpriority 是一个链接错误,表示编译器无法找到 getpriority 函数的定义。要解决此问题,需要确保正确包含头文件、正确设置编译器选项和链接库文件。 ### 回答2: error lnk2001: unresolved external symbol _getpriority是一个链接错误,意味着链接器无法解析对_getpriority的外部符号引用。 _getpriority是一个用于获取进程优先级的函数,它在Windows下没有定义,因此链接器无法找到它的定义。 要解决这个问题,可以采取以下几种方法: 1. 检查代码中是否有对_getpriority函数的调用:首先检查代码中是否存在对_getpriority函数的调用,如果没有必要使用该函数,可以删除相关的代码,这样可以避免链接错误。 2. 更改代码以使用Windows下的类似功能:如果确实需要使用进程优先级相关的功能,可以改用Windows下的类似函数来代替_getpriority。可以使用Windows API中的GetPriorityClass函数来获取进程优先级,该函数返回一个整数值表示进程的优先级类别。 3. 添加相应的库文件:如果你确定代码中需要使用_getpriority函数,可以找到包含该函数定义的库文件,并将其添加到链接器的库文件路径中。可以通过在项目属性中添加相应的附加库路径和库文件名称来实现。 总之,要解决error lnk2001: unresolved external symbol _getpriority链接错误,可以通过删除对_getpriority函数的调用、使用Windows API中的相关函数或添加相应的库文件来解决问题。 ### 回答3: 这个错误是由于在C++代码中使用了一个未解析的外部符号"getpriority"所引起的。"getpriority"是一个用于获取进程优先级的函数,属于POSIX标准库中的一部分。 在C++中,要使用"getpriority"函数,需要包含对应的头文件<sys/resource.h>,并且需要链接实现该函数的库文件。根据错误提示"error lnk2001: unresolved external symbol _getpriority",可以推断出缺少对应的库文件的链接。 解决这个问题可以按照以下步骤进行: 1. 确保正确地包含了头文件<sys/resource.h>: #include <sys/resource.h> 2. 确认编译器的选项是否正确地链接了对应的库文件。 对于使用GCC编译器的情况,需要添加"-l"参数指定链接的库文件名,例如: g++ main.cpp -o main -l库文件名 3. 如果是在Windows平台上开发,可能需要使用Cygwin或MinGW等工具链来编译和链接,以确保POSIX相关的功能可用。 此外,请注意确保包含正确的库文件,并将其放置在正确的位置,以便编译器能够找到并链接到正确的实现。 总之,"error lnk2001: unresolved external symbol _getpriority"错误是由于未能解析所需库文件中的"getpriority"函数引起的。通过检查头文件和链接选项,以及在合适的位置放置正确的库文件,可以解决这个问题
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值