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