简体   繁体   English

在Linux中从C连接到Matlab引擎

[英]Connect to Matlab engine from C in Linux

I'm trying to call the Matlab engine programatically from a C program on Linux (Matlab r2009a, Ubuntu 9.10). 我试图从Linux上的C程序(Matlab r2009a,Ubuntu 9.10)以编程方式调用Matlab引擎。

I've got my own code (which works in Windows), but for now I'm just trying to get the Matlab "engdemo.c" program to work on Linux. 我有自己的代码(适用于Windows),但是现在我只是想让Matlab“engdemo.c”程序在Linux上运行。 I have managed to compile & link it (after including about 15 -l<lib> switches on the gcc command line), and even resolved all the runtime dynamic links via some ldconfig magic. 我已经设法编译和链接它(在gcc命令行中包含大约15 -l<lib>开关之后),甚至通过一些ldconfig magic解决了所有运行时动态链接。

But, when the program runs, I just get the "Can't start MATLAB engine" error message and the program ends, with no indication of why it failed. 但是,当程序运行时,我只是得到“无法启动MATLAB引擎”错误消息并且程序结束,没有指示它失败的原因。

Has anybody made this work? 有人做过这项工作吗? What have I forgotten to do? 我忘了做什么?

ps I originally asked this on SuperUser because I think it's configuration related, but I see other Matlab engine-related ?'s here so I thought I'd give it a go. ps我最初在SuperUser上问这个,因为我觉得它与配置有关,但是我看到其他Matlab引擎相关的?在这里,所以我想我会试一试。

You should run strace on your C program to see where things go wrong. 你应该在你的C程序上运行strace以查看出错的地方。 Typically, I found that most of the time it comes down to either: 通常情况下,我发现大部分时间都归结为:

  • Not having csh installed 没有安装csh
  • Having the environment set wrong, sometimes LS_COLORS screws things up with csh 环境设置错误,有时LS_COLORS会用csh LS_COLORS

MathWorks has documented this on their website , specifically the following note: MathWorks已经在他们的网站上记录了这一点,特别是以下注释:

Note: To run MATLAB engine on the UNIX platform, you must have the C shell csh installed at /bin/csh . 注意:要在UNIX平台上运行MATLAB引擎,你必须有C shell的csh安装在/bin/csh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM