Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

engOpen() always returns 0

210 views
Skip to first unread message

Thomas Van Parys

unread,
Nov 7, 2008, 5:37:01 AM11/7/08
to
My aim is to call Matlab from a java plugin I'm writing.
I was already able to do this some time ago, but since a recent re-install, the very same application just stopped working.

The java application always returns 'Can't open engine' as the native function engOpen(char*) returns 0.

I now tried several approaches:
- calling engOpen("\0") from a simple enginedemo.c program
- calling engOpen(null) from java, using JNA mapped to libeng.so
- calling engine.engOpen() from java, using JMatLink (which uses JNI).

Every time getting an engine pointer = 0
I didn't get any errors compiling enginetest.c or compiling libJMatLink.so.

compiling C example:
gcc $(MIN) $(MLIB) -leng -lmx enginetest.c -o enginetest.out

LD_LIBRARY_PATH points to $(MATLAB)/bin/glnx86
So I'm not getting any linking errors, not when compiling, not when running... but engOpen() just fails to open a matlab engine. It simply returns 0, apparently without any further errors.

What could I be missing here?
Matlab itself works fine when I enter 'matlab' on the command line.

My system:
Fedora 9
gcc 4.3.0
Sun Java 1.6.0_10
Matlab 7.6.0 (R2008a)

Thanks for every hint about what could be going wrong here... I've already lost several days on this problem.

James Tursa

unread,
Nov 7, 2008, 11:10:18 AM11/7/08
to
"Thomas Van Parys" <thpar@plantsystemsbiology-abbreviatethis-.ugent.be> wrote in message <gf15od$8ij$1...@fred.mathworks.com>...
.
If you are on Windows, try opening a Command Window (Start, All Programs, Accessories, Command Window), and then enter the following:
.
matlab /regserver
.
Then try your engine app again.
.
James Tursa
.

Thomas Van Parys

unread,
Nov 7, 2008, 12:01:03 PM11/7/08
to
"James Tursa" <aclassyguy...@hotmail.com> wrote in message <gf1p9a$puk$1...@fred.mathworks.com>...

> "Thomas Van Parys" <thpar@plantsystemsbiology-abbreviatethis-.ugent.be> wrote in message <gf15od$8ij$1...@fred.mathworks.com>...
> > My system:
> > Fedora 9
> > gcc 4.3.0
> > Sun Java 1.6.0_10
> > Matlab 7.6.0 (R2008a)
> >
> > Thanks for every hint about what could be going wrong here... I've already lost several days on this problem.
> .
> If you are on Windows, try opening a Command Window (Start, All Programs, Accessories, Command Window), and then enter the following:
> .
> matlab /regserver
> .
> Then try your engine app again.
> .

Dear James,

Thanks for your reply. I'm aware that in Windows, you have to register Matlab in order to get the engine working, but as said, I'm on a Fedora 9 installation.

The only progress I've made today, is test my little c-program on a RedHat-server with gcc 4.1.2 and Matlab 7.5.0. Compilation and running/opening the engine worked flawless. So now I'm sure my makefile and c program are correct.
So what could still be wrong in my local installation?

regards,
Thomas

James Tursa

unread,
Nov 8, 2008, 4:40:18 PM11/8/08
to
"Thomas Van Parys" <thpar@plantsystemsbiology-abbreviatethis-.ugent.be> wrote in message <gf1s8f$7uq$1...@fred.mathworks.com>...
>
> ... but as said, I'm on a Fedora 9 installation. ...
>
Ah, so you did. And all this time I thought a fedora was a hat ...
.
Sorry I can't help you more. I'm on WinXP and am (obviously) unfamiliar with the Fedora 9 Linux installation.
.
James Tursa
.

Boye

unread,
Nov 9, 2008, 12:19:02 PM11/9/08
to
Hi Thomas,

I had the same problem a few days ago on the newest Ubuntu distro. I suggest you check the following:

- Do you have csh installed? engOpen tries to run matlab through csh.

- If csh is present, is matlab on the csh search path? On my system, Matlab installs to /opt/matlab/bin, with a symlink from /usr/local/share. Neither is on PATH by default (this pertains to bash, I'm just guessing that csh works similarly).

- You should be able to run '/bin/csh -f -c <matlab>' from the command line, where <matlab> is whatever argument you send to engOpen, or simply "matlab" if you send NULL. This is the command launched by engOpen.

- Finally, if all else fails, put a call to engOpen into a minimal test
program and try 'strace -f ./test-matlab 2>&1 |less'. You might be able to track down the source of the problem this way. engOpen forks/clones, the -f argument to strace makes sure it tracks the child process as well. This was at least how I found the problem on my system: the call to csh returned '-1
ENOENT (No such file or directory)'

Regards and good luck,

Boye

Thomas Van Parys

unread,
Nov 10, 2008, 10:10:03 AM11/10/08
to
"Boye " <boyeah@gmail-delete-this-.com> wrote in message <gf7626$r2i$1...@fred.mathworks.com>...

> Hi Thomas,
>
> I had the same problem a few days ago on the newest Ubuntu distro. I suggest you check the following:
>
> - Do you have csh installed? engOpen tries to run matlab through csh.
>

Hi Boye,

Your post just made my day!
Indeed, the only thing I needed to do was install csh and everything started working again.
And to think I lost a week on this...

Thank you very much,
Thomas

Oren

unread,
Nov 29, 2012, 8:17:08 AM11/29/12
to
"Thomas Van Parys" wrote in message <gf9isb$liv$1...@fred.mathworks.com>...
Hi,
Unfortunately i have same problem in Windows XP,
the engOpen always return NULL, I tried everything i saw on the web:
register, use NULL at the call of the function, check libs from one location and the correct one, everything I found, i just cant get the matlab to open an engine pointer ,
I need help please...
Thanks,
Oren

Abe

unread,
Feb 11, 2016, 3:21:17 PM2/11/16
to
"Thomas Van Parys" wrote in message <gf15od$8ij$1...@fred.mathworks.com>...
This might help
https://www.youtube.com/watch?v=kVX3Yq7s88g
0 new messages