Error using mex complier

6 ビュー (過去 30 日間)
Jaimeet Patel
Jaimeet Patel 2019 年 8 月 15 日
回答済み: Geoff Hayes 2019 年 8 月 19 日
Unable to compile C++ code. I am using the following command to complie a .cpp file, but it throws an error.
mex generateEllipseCandidates.cpp -IC:\opencv\build\include -IC:\opencv\build\include\opencv -IC:\opencv\build\include\opencv2 -IC:\opencv\build\x64\vc11\lib -Lopencv_core249 -Lopencv_highgui249 -Lopencv_imgproc249 -Llibmwlapack.lib -IC:\Users\jaimeetp\Documents\MATLAB\R2019a\extern\include -IC:\Users\jaimeetp\Documents\MATLAB\R2019a\extern\lib\win64\microsoft
Error:
mex generateEllipseCandidates.cpp -IC:\opencv\build\include -IC:\opencv\build\include\opencv -IC:\opencv\build\include\opencv2 -IC:\opencv\build\x64\vc11\lib -Lopencv_core249 -Lopencv_highgui249 -Lopencv_imgproc249 -Llibmwlapack.lib -IC:\Users\jaimeetp\Documents\MATLAB\R2019a\extern\include -IC:\Users\jaimeetp\Documents\MATLAB\R2019a\extern\lib\win64\microsoft
Building with 'Microsoft Visual C++ 2019'.
Error using mex
Creating library generateEllipseCandidates.lib and object generateEllipseCandidates.exp
generateEllipseCandidates.obj : error LNK2019: unresolved external symbol dggev referenced in function "int __cdecl fitEllipse2(double *,double *)"
(?fitEllipse2@@YAHPEAN0@Z)
generateEllipseCandidates.obj : error LNK2019: unresolved external symbol "public: __cdecl 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@@QEAA@HAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@00H@Z) referenced in function "void __cdecl cvCanny3(void const *,void
*,void *,void *,int)" (?cvCanny3@@YAXPEBXPEAX11H@Z)
generateEllipseCandidates.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl cv::Exception::~Exception(void)" (??1Exception@cv@@UEAA@XZ)
referenced in function "void __cdecl cvCanny3(void const *,void *,void *,void *,int)" (?cvCanny3@@YAXPEBXPEAX11H@Z)
generateEllipseCandidates.obj : error LNK2019: unresolved external symbol "void __cdecl cv::error(class cv::Exception const &)" (?error@cv@@YAXAEBVException@1@@Z)
referenced in function "void __cdecl cvCanny3(void const *,void *,void *,void *,int)" (?cvCanny3@@YAXPEBXPEAX11H@Z)
generateEllipseCandidates.obj : error LNK2019: unresolved external symbol "void __cdecl cv::fastFree(void *)" (?fastFree@cv@@YAXPEAX@Z) referenced in function
"public: __cdecl cv::Mat::~Mat(void)" (??1Mat@cv@@QEAA@XZ)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual class cv::Mat __cdecl cv::_InputArray::getMat(int)const "
(?getMat@_InputArray@cv@@UEBA?AVMat@2@H@Z)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl cv::_InputArray::getMatVector(class std::vector<class
cv::Mat,class std::allocator<class cv::Mat> > &)const " (?getMatVector@_InputArray@cv@@UEBAXAEAV?$vector@VMat@cv@@V?$allocator@VMat@cv@@@std@@@std@@@Z)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual class cv::GlBuffer __cdecl cv::_InputArray::getGlBuffer(void)const "
(?getGlBuffer@_InputArray@cv@@UEBA?AVGlBuffer@2@XZ)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual class cv::GlTexture __cdecl cv::_InputArray::getGlTexture(void)const "
(?getGlTexture@_InputArray@cv@@UEBA?AVGlTexture@2@XZ)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual class cv::gpu::GpuMat __cdecl cv::_InputArray::getGpuMat(void)const "
(?getGpuMat@_InputArray@cv@@UEBA?AVGpuMat@gpu@2@XZ)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl cv::_InputArray::kind(void)const "
(?kind@_InputArray@cv@@UEBAHXZ)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual class cv::Size_<int> __cdecl cv::_InputArray::size(int)const "
(?size@_InputArray@cv@@UEBA?AV?$Size_@H@2@H@Z)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual unsigned __int64 __cdecl cv::_InputArray::total(int)const "
(?total@_InputArray@cv@@UEBA_KH@Z)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl cv::_InputArray::type(int)const "
(?type@_InputArray@cv@@UEBAHH@Z)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl cv::_InputArray::depth(int)const "
(?depth@_InputArray@cv@@UEBAHH@Z)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl cv::_InputArray::channels(int)const "
(?channels@_InputArray@cv@@UEBAHH@Z)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl cv::_InputArray::empty(void)const "
(?empty@_InputArray@cv@@UEBA_NXZ)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl cv::_OutputArray::fixedSize(void)const "
(?fixedSize@_OutputArray@cv@@UEBA_NXZ)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl cv::_OutputArray::fixedType(void)const "
(?fixedType@_OutputArray@cv@@UEBA_NXZ)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl cv::_OutputArray::needed(void)const "
(?needed@_OutputArray@cv@@UEBA_NXZ)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual class cv::Mat & __cdecl cv::_OutputArray::getMatRef(int)const "
(?getMatRef@_OutputArray@cv@@UEBAAEAVMat@2@H@Z)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl cv::_OutputArray::create(class
cv::Size_<int>,int,int,bool,int)const " (?create@_OutputArray@cv@@UEBAXV?$Size_@H@2@HH_NH@Z)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl cv::_OutputArray::create(int,int,int,int,bool,int)const "
(?create@_OutputArray@cv@@UEBAXHHHH_NH@Z)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl cv::_OutputArray::create(int,int const
*,int,int,bool,int)const " (?create@_OutputArray@cv@@UEBAXHPEBHHH_NH@Z)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl cv::_OutputArray::release(void)const "
(?release@_OutputArray@cv@@UEBAXXZ)
generateEllipseCandidates.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl cv::_OutputArray::clear(void)const "
(?clear@_OutputArray@cv@@UEBAXXZ)
generateEllipseCandidates.obj : error LNK2019: unresolved external symbol "public: class cv::Mat & __cdecl cv::Mat::operator=(class cv::Scalar_<double> const &)"
(??4Mat@cv@@QEAAAEAV01@AEBV?$Scalar_@N@1@@Z) referenced in function "public: __cdecl cv::Mat_<float>::Mat_<float>(int,int,float const &)"
(??0?$Mat_@M@cv@@QEAA@HHAEBM@Z)
generateEllipseCandidates.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 "void __cdecl calculateGradient3(double *,unsigned int,unsigned int,struct image_double_s * *)"
(?calculateGradient3@@YAXPEANIIPEAPEAUimage_double_s@@@Z)
generateEllipseCandidates.obj : error LNK2019: unresolved external symbol "public: void __cdecl cv::Mat::create(int,int const *,int)"
(?create@Mat@cv@@QEAAXHPEBHH@Z) referenced in function "public: __cdecl cv::Mat_<float>::Mat_<float>(int,int,float const &)" (??0?$Mat_@M@cv@@QEAA@HHAEBM@Z)
generateEllipseCandidates.obj : error LNK2019: unresolved external symbol "public: void __cdecl cv::Mat::deallocate(void)" (?deallocate@Mat@cv@@QEAAXXZ) referenced
in function "public: __cdecl cv::Mat::~Mat(void)" (??1Mat@cv@@QEAA@XZ)
generateEllipseCandidates.obj : error LNK2019: unresolved external symbol "public: void __cdecl cv::Mat::copySize(class cv::Mat const &)"
(?copySize@Mat@cv@@QEAAXAEBV12@@Z) referenced in function "public: __cdecl cv::Mat::Mat(class cv::Mat const &)" (??0Mat@cv@@QEAA@AEBV01@@Z)
generateEllipseCandidates.obj : error LNK2019: unresolved external symbol "void __cdecl cv::line(class cv::Mat &,class cv::Point_<int>,class cv::Point_<int>,class
cv::Scalar_<double> const &,int,int,int)" (?line@cv@@YAXAEAVMat@1@V?$Point_@H@1@1AEBV?$Scalar_@N@1@HHH@Z) referenced in function mexFunction
generateEllipseCandidates.obj : error LNK2019: unresolved external symbol "void __cdecl cv::ellipse(class cv::Mat &,class cv::Point_<int>,class
cv::Size_<int>,double,double,double,class cv::Scalar_<double> const &,int,int,int)"
(?ellipse@cv@@YAXAEAVMat@1@V?$Point_@H@1@V?$Size_@H@1@NNNAEBV?$Scalar_@N@1@HHH@Z) referenced in function mexFunction
generateEllipseCandidates.obj : error LNK2019: unresolved external symbol "int __cdecl cv::_interlockedExchangeAdd(int *,int)"
(?_interlockedExchangeAdd@cv@@YAHPEAHH@Z) referenced in function "public: __cdecl cv::Mat::Mat(class cv::Mat const &)" (??0Mat@cv@@QEAA@AEBV01@@Z)
generateEllipseCandidates.obj : error LNK2019: unresolved external symbol cvGetMat referenced in function "void __cdecl cvCanny3(void const *,void *,void *,void
*,int)" (?cvCanny3@@YAXPEBXPEAX11H@Z)
generateEllipseCandidates.obj : error LNK2019: unresolved external symbol cvSobel referenced in function "void __cdecl cvCanny3(void const *,void *,void *,void
*,int)" (?cvCanny3@@YAXPEBXPEAX11H@Z)
generateEllipseCandidates.mexw64 : fatal error LNK1120: 36 unresolved externals
  2 件のコメント
Geoff Hayes
Geoff Hayes 2019 年 8 月 16 日
Jaimeet - could you clarify the following (from your call to mex)
-IC:\opencv\build\x64\vc11\lib -Lopencv_core249 -Lopencv_highgui249 -Lopencv_imgproc249 -Llibmwlapack.lib
It seems that you are using the
-I
to indicate where the libraries should be found. Unless MATLAB does things differently, this is used only to add the include directory of header files. You should be using
-L
for libraries. And when indicating which libraries to link to, you use the lower case
-l
(and probably need to include "lib" as well). So the above might become
-LC:\opencv\build\x64\vc11\lib -llibopencv_core249 -llibopencv_highgui249 -llibopencv_imgproc249 -llibmwlapack
See mex for some examples.
Jaimeet Patel
Jaimeet Patel 2019 年 8 月 16 日
Thank you. It worked for me. Thank you for your suggestion.

サインインしてコメントする。

回答 (1 件)

Geoff Hayes
Geoff Hayes 2019 年 8 月 19 日
Jaimeet - it seems that you are using the
-I
to indicate where the libraries should be found. Unless MATLAB does things differently, this is used only to add the include directory of header files. You should be using
-L
for libraries. And when indicating which libraries to link to, you use the lower case
-l
(and probably need to include "lib" as well). So the above might become
-LC:\opencv\build\x64\vc11\lib -llibopencv_core249 -llibopencv_highgui249 -llibopencv_imgproc249 -llibmwlapack
See mex for some examples.

カテゴリ

Help Center および File ExchangeWrite C Functions Callable from MATLAB (MEX Files) についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by