在最大流量/最小剪切算法中链接mex文件时出错

问题描述

|| 我正在尝试在MATLAB中实现“基于GrabCut的对象分割技术”方法。为了最小化马尔可夫随机场能量函数,我使用了此处提供的标准最大流量/最小剪切算法:http://vision.csd.uwo.ca/code/ 问题:当我尝试创建一个mex文件来调用MATLAB中的Graph创建和最小化函数时,出现以下错误:   未定义的符号:     \“ Graph :: Graph(int,int,void()(char))\”,引用自:         GraphTest.o中的_mexFunction      ld:找不到符号   collect2:ld返回1退出状态      混合:\'\“ GraphTest.mexmaci64 \” \'的链接失败。 我的代码确实非常简单,只是复制了README文件中提到的一部分代码,如下所示:
#include \"mex.h\"
#include <stdio.h>
#include <math.h>
#include \"graph.h\"

void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]) 
{    
    typedef Graph<int,int,int> GraphType;
  GraphType *g = new GraphType(/*estimated # of nodes*/ 2,/*estimated # of edges*/1); 
}
如果曾经使用过此软件包或经历过类似错误的任何人都可以提供对该问题的一些见解,我将不胜感激。 提前致谢!     

解决方法

我想您正在使用Matlab进行编译? 尝试: 梅克斯GraphTest.cpp graph.cpp 我假设您的mex网关文件是GraphTest.cpp。您可以将任何依赖项标记到最后。这对于简单的项目来说相当不错。当它变大时,您将想要切换到带有依赖项的实际构建系统。我更喜欢CMake。     

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...