Malte
Malte

Reputation: 955

Linking Matlab and Java: Library JMatLink.dll cannot be loaded

I want to use JMatLink to connect Java with Matlab. I need to use this specific library since it is integrated in the projeny code. I have followed the steps from the documentation / other forums:

However, when I try to run the class SimpleGuiTest, I get the following error message:

ERROR:  Could not load the JMatLink library
Win:   This error occures, if the path to
    MATLAB's <matlab>\bin directory is
    not set properly.
    Or if JMatLink.dll is not found.

Linux: Check if <matlab>/extern/lib/glnx86 (libeng.so, libmat.so, etc.)
    and <matlab>/sys/os/glnx86 (libstdc++-libc6.1-2.so.3) are in your path.

    (you can also copy missing libraries to your local path).

and

Exception in thread "main" java.lang.UnsatisfiedLinkError: jmatlink.CoreJMatLink.setDebugNATIVE(Z)V

I have changed the code where the library gets loaded from

            System.loadLibrary("JMatLink");

To a command with absolute path

            System.load("C:\\Windows\\System32\\JMatLink.dll");

But I am still getting the same error message. Is it possible that the .dll is not compatible with my Win 8.1 and Matlab R2014a environment? Do I have to compile a new one for my environment? Or is there anything else that I am missing?

Upvotes: 0

Views: 328

Answers (1)

Taco
Taco

Reputation: 11

I've also tried to install it without any luck a while back. I belive the reason is, as you state, that the .dll is not compatible with 64-bit operating systems/Matlab. If I remember correctly, a few of the dependencies it requires some 32-bit system libraries which was not found in my version of Windows 7 (64-bit). To map the missing dependencies I used dependencies-walker.

I had a go at compiling the source code as well, but you need to have an older version of Matlab6.5 (according to the build file) in order to compile it with the accompanying build file. More modern versions of Matlab such as 2014a does not have support for the aging borland compiler used by the build file. When trying to compile the library with Borland 5.5.1, MatlabR2012b, JavaSE1.4.2 it gives me the error:

compile:
 [exec] Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
 [exec] Error E2194: Could not find file 'Files\MATLAB\R2012b\extern\include.cpp'
 [exec] Error E2194: Could not find file 'Files\MATLAB\R2012b\simulink\include.cpp'

It might be that you can find a way to build it with a modern supported compiler or if you get your hands on an older version of Matlab, but at this point I gave up that approached and created a wrapper using the matlabcontrol-fork matconsolectl.

Hope my experience has been helpful in some way.

Upvotes: 1

Related Questions