gpt4 book ai didi

c++ - 如何通过调用 c++ dll 来运行 Matlab 文件

转载 作者:行者123 更新时间:2023-11-30 05:17:49 25 4
gpt4 key购买 nike

我正在尝试从此链接运行 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。

但失败了:

enter image description here

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

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

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

最佳答案

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

将文件 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"

评论说“对于 Mac Os X 系统使用这一行:

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

它不会工作,因为它指的是旧版本的 Matlab。

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

#include "mex.h"

关于c++ - 如何通过调用 c++ dll 来运行 Matlab 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42053732/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com