在Max-flow / min-cut算法中链接mex文件时出错

时间:2011-05-02 04:08:01

标签: matlab computer-vision mex image-segmentation

我正在尝试在MATLAB中实现“基于GrabCut的对象分割技术”方法。为了最小化马尔可夫随机场能量函数,我使用了此处提供的标准Max-flow / min-cut算法:http://vision.csd.uwo.ca/code/

问题:当我尝试创建一个mex文件来调用MATLAB中的Graph创建和最小化函数时,我收到以下错误:

  

未定义的符号:     “Graph :: Graph(int,int,void()(char ))”,引自:         GraphTest.o中的_mexFunction

     

ld:找不到符号   collect2:ld返回1退出状态

     

mex:'“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); 
}

如果之前使用过这个软件包或遇到过类似错误的人,我会非常感激,可以对这个问题提供一些见解。

提前致谢!

1 个答案:

答案 0 :(得分:2)

我认为你是用Matlab编译的?

尝试:

mex GraphTest.cpp graph.cpp

我假设你的mex网关文件是GraphTest.cpp。任何依赖项,您只需标记到最后。这对于简单的项目来说效果相当好。当它变大时,你会想要切换到具有依赖性的实际构建系统。我更喜欢CMake。