【问题标题】:Error while linking mex files in Max-flow/min-cut algorithm在 Max-flow/min-cut 算法中链接 mex 文件时出错
【发布时间】:2011-05-02 04:08:00
【问题描述】:

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

问题:当我尝试在 MATLAB 中创建 mex 文件来调用 Graph 创建和最小化函数时,出现以下错误:

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

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); 
}

如果任何曾经使用过此软件包或遇到过类似错误的人能够提供一些关于该问题的见解,我将不胜感激。

提前致谢!

【问题讨论】:

  • 您使用什么编译器/链接器?你能提供你用来编译/链接的命令吗?此外,您是否编译并链接到Graph.cpp(或任何其他实现该类的文件)?
  • 谢谢伊塔玛。我只是使用“mex GraphTest.cpp”进行编译。

标签: matlab computer-vision mex image-segmentation


【解决方案1】:

我猜你是用 Matlab 编译的?

试试:

mex GraphTest.cpp graph.cpp

我假设您的 mex 网关文件是 GraphTest.cpp。您可以将任何依赖项标记到末尾。这对于简单的项目相当有效。当它变大时,您将需要切换到具有依赖关系的实际构建系统。我更喜欢 CMake。

【讨论】:

  • 谢谢 pxu.. 成功了!我最初只使用“mex GraphTest.cpp”进行编译
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-19
  • 2014-07-12
  • 1970-01-01
  • 1970-01-01
  • 2021-11-15
  • 1970-01-01
相关资源
最近更新 更多