Mac OSX上的engdemo.c - 无法启动MATLAB引擎

时间:2014-10-03 17:45:49

标签: macos matlab matlab-engine

我正在尝试构建并运行Matlab Engine示例" engdemo.c"使用Mathworks中的instructions。当我尝试使用!./engdemo命令运行它时,我收到以下错误:

matlab: Command not found.
Can't start MATLAB engine

我还没有在其他相关的StackOverflow帖子中找到解决方案(例如matlab engine “Can't start MATLAB engine"How solve the “Can't start MATLAB engine” command? [closed]

我在/ bin / csh安装了csh(通过键入which csh来检查)。

我的PATH变量上有Matlab,我根据Mac OSX的Mathworks instructions设置了DYLD_LIBRARY_PATH变量。以下是我在.bash_profile中包含的用于设置这些环境变量的行:

# Settings for Matlab Engine using Apple XCode
export PATH=$PATH:/Applications/MATLAB_R2014a.app/bin
export PATH=$PATH:/Applications/MATLAB_R2014a.app/bin/maci64
export DYLD_LIBRARY_PATH=/Applications/MATLAB_R2014a.app/bin/maci64:/Applications/MATLAB_R2014a.app/sys/os/maci64:$DYLD_LIBRARY_PATH

最终我想构建一个使用Matlab脚本的C程序(理想情况下使用XCode构建),但即使让演示工作也很麻烦令人沮丧。

1 个答案:

答案 0 :(得分:0)

我使用Mathworks中的these instructions让它工作。关键的区别在于我用mex编译engdemo.c的方式。在我使用mex -client engine engdemo.c之前(见上文),但是当我尝试从Matlab提示或从我的shell运行演示时,我会遇到错误。

在该文章之后,我改为使用以下内容进行编译:{{1​​}}。起初,这引发了一个错误,说它无法找到SDK“macosx10.7”(注意我使用的是OSX 10.9)。我查看了engopts.sh并发现了很多对macosx10.7的引用。

this article之后,我通过将对macosx10.7的所有引用更改为macosx10.8来编辑engopts.sh。 (请注意,即使我有osx10.9,我也有10.8 SDK,您可以通过键入mex -f /Applications/MATLAB_R2014a.app/bin/engopts.sh ./engdemo.c xcode-select -print-path find来查看。我决定使用10.8因为在那里有人说当他们使用10.9时其他东西都破了,但我还没有自己检查过。)

进行这些更改后,我重新运行了-name MacOSX10.8.sdk,它运行正常。从shell运行./engdemo成功运行程序。对我来说,这似乎仍然非常虚伪。