views:

134

answers:

2

I'm trying to call the Matlab engine programatically from a C program on Linux (Matlab r2009a, Ubuntu 9.10).

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. 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.

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.

Has anybody made this work? What have I forgotten to do?

p.s. 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.

+3  A: 

You should run strace on your C program to see where things go wrong. Typically, I found that most of the time it comes down to either:

  • Not having csh installed
  • Having the environment set wrong, sometimes LS_COLORS screws things up with csh
Adam Goode
Nice call--installing tcsh did the trick. Thanks!
Drew Hall
BTW, thanks for the tip about strace--I didn't even know that existed!
Drew Hall
A: 

Hey I recently got the Matlab Engine working in Linux. I have written a short tutorial of the various steps. The link below may be of help to you. http://www.umiacs.umd.edu/~jsp/Downloads.html

Regards Jai

Jai Pillai
Thanks, Jai. It might be useful to mention something about prerequisites/required packages in your tutorial. Needing csh/tcsh is something that never would have occurred to me if Adam hadn't suggested it. BTW, I was using my x86 laptop, rather than x86-64 as you were, for what it's worth.
Drew Hall