【问题标题】:How to run a Matlab file with calling a c++ dll如何通过调用 c++ dll 运行 Matlab 文件
【发布时间】:2017-02-06 04:54:26
【问题描述】:

我正在尝试从此链接运行 Matlab 代码:(请参阅底部的下载部分) http://cvn.ecp.fr/personnel/iasonas/sketch.html

我下载源代码后,按照readme.pdf中的步骤操作

我正在运行 Matlab R2014a 的 demo1

1.) 将根文件夹及其所有子文件夹放在 Matlab 路径中。

另外,

我进入过滤子文件夹,然后执行命令

mex iir_gauss.cpp 

显示MEX成功完成后。我尝试在kdtree/src子文件夹中编译kdtree.cc。

但是失败了:

错误消息是:c:\users\user\desktop\ps_primal_sketch\ps_primal_sketch\kdtree\src\kdtree_common.h(20):致命错误 C1083:无法打开 包含文件:'/Applications/MATLAB6p5p1/extern/include/mex.h':没有这样的文件或目录

没有编译文件,我无法运行demo1,因为调用其中一个函数(kdtree)失败。

谁能教我如何执行文件(demo1)?我看到在kdtree\mex\win 子文件夹中有一个kdtree.dll,我需要重新编译kdtree.cc 文件吗?请详细教教我,因为我是Matlab的初学者,谢谢。

【问题讨论】:

  • 你先mex -setup了吗?
  • 如果你运行的是Matlab R2014a,错误信息怎么会引用文件夹MATLAB6p5p1

标签: c++ matlab


【解决方案1】:

我想我解决了这个难题......

将文件kdtree_common.h中的第20行替换为#include "mex.h"


问题在于您下载的源代码。

kdtree_common.h的开头。
它看起来如下:

// Guy Shechter
// June 2004
// 
// Uncomment one of these includes depending on your architecture.
// Your installation location may vary.
//
//
// For Linux use this line:
//
//#include "/usr/local/matlab/extern/include/mex.h"
//
//
// For Windows systems use this line:
//
//#include "c:\matlab6p1\extern\include\mex.h"
//
//
// For Mac Os X systems use this line :
//
#include "/Applications/MATLAB6p5p1/extern/include/mex.h"
//
//

如您所见,包含路径指的是"/Applications/MATLAB6p5p1/extern/include/mex.h"

评论说“For Mac Os X systems use this line :

由于您使用的是 Windows 操作系统,因此您应该将其放在评论中,并从评论中删除 #include "c:\matlab6p1\extern\include\mex.h"

它不起作用,因为它引用的是旧版本的 Matlab。

您不需要使用完整路径,只需将其替换为:

#include "mex.h"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-08
    相关资源
    最近更新 更多