错误 LNK2019:matlab 中未解析的外部符号

Posted

技术标签:

【中文标题】错误 LNK2019:matlab 中未解析的外部符号【英文标题】:Error LNK2019: unresolved external symbol in matlab 【发布时间】:2014-04-29 04:57:41 【问题描述】:

我已经在这里工作了 2 天,并尝试了所有可以通过搜索引擎找到的解决方案。但我还是卡在这里。

我从here下载了一个超像素实现包。

该函数使用 C++ 编写,但已为 Linux 64 位操作系统生成了一个 mex 文件。我使用的是 Windows 8 64 位,所以我必须为我的系统生成一个 mex 文件。

网站的包中已经提供了这些文件。在 mex 设置并提供正确的 openCV 路径和环境变量之后,我运行了代码 compile_mex.m

mex -IB:\Opencv\opencv\build\include\opencv -c seeds2.cpp

mex mexSEEDS.cpp -IB:\Opencv\opencv\build\include\opencv seeds2.obj

我收到以下错误,无法找到解决方案

mexSEEDS.obj : error LNK2019: unresolved external symbol cvSaveImage referenced in function "void __cdecl SaveImage(unsigned int *,int const &,int const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?SaveImage@@YAXPEAIAEBH1AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

我无法通过这个。当我在代码块中执行此操作时,我得到了同样的错误,即使在链接了许多站点/论坛所建议的库、编译器目录和链接器库和目录之后也是如此。

【问题讨论】:

【参考方案1】:

我得到了答案。

    找到并打开 mexopts.bat 访问此pdf 按照设置 MATLAB 编译 C++ 和 MATLAB MEX 文件并将它们与 OPENCV OBJ 文件链接

    在编辑 mexopts.bat 时,在向 LINKFLAGS 添加库时,从 /build/x64/vc10/lib 中添加以下库

    core249 and 249d
    flann249 (and the same as above. rest also have the tag 249 and 249d. this is the version number. 2.4.9 in my case)
    highgui
    imageproc
    legacy
    objdetect
    

原因是所有这些都是编译 mexseeds.cpp 所必需的。但基本至少是第一个 4. 添加保存并编译 mex 文件后。在 pdf 中,库名称会有所不同,因为它是在旧版本的 opencv 期间创建的

【讨论】:

以上是关于错误 LNK2019:matlab 中未解析的外部符号的主要内容,如果未能解决你的问题,请参考以下文章

LNK2019:错误。使用 InternetOpen InternetReadFIle 的 C++ 程序中未解析的外部符号

Google Test:错误LNK2019:Visual Studio 2013中未解析的外部符号

在 Visual Studio 中构建 MATLAB mex 文件会给出“函数 mexFunction 中引用的 LNK2019 未解析的外部符号 _mexPrintf”?

错误 LNK2019:无法解析的外部符号“extern”C”这是啥错误?

错误 LNK2019:无法解析的外部符号“extern”C”这是啥错误?

vc ++ MFC应用程序,错误LNK2019:未解析的外部符号