_Jennifer 2015-04-03 02:14 采纳率: 100%
浏览 9371
已采纳

matlab进行mex时出现 error LNK2019: 无法解析的外部符号……

  **具体问题是:我想把现有的.cpp文件转成.mexw32的文件,代码没有出现错误,因为前辈曾转出过64位的。**

而且配置应该没问题,因为mex代码中其他.cpp文件是可以做出来的,唯独这个出现以下错误:
mex mex_maxflow.cpp
正在创建库 C:\DOCUME~1\ADMINI~1\LOCALS~1\TEMP\MEX_4W~1\templib.x 和对象 C:\DOCUME~1\ADMINI~1\LOCALS~1\TEMP\MEX_4W~1\templib.exp
mex_maxflow.obj : error LNK2019: 无法解析的外部符号 "public: thiscall Graph::~Graph(void)" (??1?$Graph@NNN@@QAE@XZ),该符号在函数 "public: void * __thiscall Graph::`scalar deleting destructor'(unsigned int)" (??_G?$Graph@NNN@@QAEPAXI@Z) 中被引用
mex_maxflow.obj : error LNK2019: 无法解析的外部符号 "private: void __thiscall Graph::reallocate_nodes(int)" (?reallocate_nodes@?$Graph@NNN@@AAEXH@Z),该符号在函数 "public: int __thiscall Graph::add_node(int)" (?add_node@?$Graph@NNN@@QAEHH@Z) 中被引用
mex_maxflow.obj : error LNK2019: 无法解析的外部符号 "private: void __thiscall Graph::reallocate_arcs(void)" (?reallocate_arcs@?$Graph@NNN@@AAEXXZ),该符号在函数 "public: void __thiscall Graph::add_edge(int,int,double,double)" (?add_edge@?$Graph@NNN@@QAEXHHNN@Z) 中被引用
mex_maxflow.obj : error LNK2019: 无法解析的外部符号 "public: double __thiscall Graph::maxflow(bool,class Block *)" (?maxflow@?$Graph@NNN@@QAEN_NPAV?$Block@H@@@Z),该符号在函数 _mexFunction 中被引用
mex_maxflow.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall Graph::Graph(int,int,void (
cdecl*)(char *))" (??0?$Graph@NNN@@QAE@HHP6AXPAD@Z@Z),该符号在函数 _mexFunction 中被引用
mex_maxflow.mexw32 : fatal error LNK1120: 5 个无法解析的外部命令

E:\MATLAB~3\BIN\MEX.PL: Error: Link of 'mex_maxflow.mexw32' failed.

折腾好久了也没结果,我试着更改文件名也存在错误,查了很多资料有些用vs编译的说是.lib调用问题,不过感觉和matlab进行mex是两回事么?好像是编译的文件引用了mexFuntion中文件,就是上面错误中说到的。请大家帮忙分析一下,不胜感激。仅有的1c币奉上
  • 写回答

4条回答

  • oyljerry 2015-04-03 15:42
    关注

    应该是你当前的cpp有用其他cpp中实现的类,函数等,造成link的时候找不到实现。
    你可以把用到的其他cpp文件中的实现复制一份到当前cpp。再编译。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗