Thread Subject: engOpen() always returns 0

Subject: engOpen() always returns 0

From: Thomas Van Parys

Date: 7 Nov, 2008 10:37:01

Message: 1 of 6

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.

Subject: engOpen() always returns 0

From: James Tursa

Date: 7 Nov, 2008 16:10:18

Message: 2 of 6

"Thomas Van Parys" <thpar@plantsystemsbiology-abbreviatethis-.ugent.be> wrote in message <gf15od$8ij$1@fred.mathworks.com>...
> 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.
.
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
.

Subject: engOpen() always returns 0

From: Thomas Van Parys

Date: 7 Nov, 2008 17:01:03

Message: 3 of 6

"James Tursa" <aclassyguywithaknotac@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

Subject: engOpen() always returns 0

From: James Tursa

Date: 8 Nov, 2008 21:40:18

Message: 4 of 6

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

Subject: engOpen() always returns 0

From: Boye

Date: 9 Nov, 2008 17:19:02

Message: 5 of 6

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

Subject: engOpen() always returns 0

From: Thomas Van Parys

Date: 10 Nov, 2008 15:10:03

Message: 6 of 6

"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

Tags for this Thread

Everyone's Tags:

engopen(2), c(2), java, linux, engine

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
linux Boye 9 Nov, 2008 12:20:08
engopen Boye 9 Nov, 2008 12:20:08
c Nick Clark 7 Nov, 2008 11:29:41
java Thomas Van Parys 7 Nov, 2008 05:40:05
engopen Thomas Van Parys 7 Nov, 2008 05:40:05
c Thomas Van Parys 7 Nov, 2008 05:40:05
engine Thomas Van Parys 7 Nov, 2008 05:40:05
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com