Error configuring MATLAB to work with OpenSim 4.0

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
Michael Fanton
Posts: 11
Joined: Sun Jan 22, 2017 12:21 pm

Error configuring MATLAB to work with OpenSim 4.0

Post by Michael Fanton » Fri Apr 13, 2018 9:44 am

I am trying to configure OpenSim 4.0 Beta so that I can use Matlab scripting. I had previously installed Opensim 3.3 (Opensim 3.3 is still installed on my system) and had it working with Matlab. I can successfully run the configureOpenSim.m script from the 4.0.Beta download, and have changed both my user and System variables to contain: "C:\OpenSim 4.0.Beta\bin".

However, when I try to load in an Opensim model, I get the following error:

Failed to load one or more dynamic libraries for OpenSim.
java.lang.UnsatisfiedLinkError: C:\OpenSim 4.0.Beta\bin\osimJavaJNI.dll: Can't find dependent libraries
Make sure OpenSim's bin directory is on your PATH.
See https://simtk-confluence.stanford.edu/d ... ith+Matlab
Error using OpenSimCreateTugOfWarModel (line 37)
Java exception occurred:
java.lang.UnsatisfiedLinkError: org.opensim.modeling.opensimSimulationJNI.new_Model__SWIG_0()J

at org.opensim.modeling.opensimSimulationJNI.new_Model__SWIG_0(Native Method)

at org.opensim.modeling.Model.<init>(Model.java:779)

I have triple checked that C:\OpenSim 4.0.Beta\bin is on my system path, and that C:\OpenSim 4.0.Beta\bin\osimJavaJNI.dll exits.


A few other things: I am running Matlab 2015b, and Opensim 3.3 is still installed on the system, although I removed its path from my system variables.

Does anyone have any tips on what to try next?

Thanks for your help,
Michael

User avatar
Ayman Habib
Posts: 2252
Joined: Fri Apr 01, 2005 12:24 pm

Re: Error configuring MATLAB to work with OpenSim 4.0

Post by Ayman Habib » Fri Apr 13, 2018 10:10 am

Dear Michael,

Thanks for reporting.

The message suggests that the JNI library is actually found but that other libraries that it depends on are not found. Possible reasons:
1. Finding the wrong/mixed low level libraries (e.g. simbody) on your path first, or some 32 bit version somehow.
2. Redistributable that goes with VS 2017 (used to build OpenSim 4.0 Beta) was never run on your machine. We normally run this during installation but it's possible the current beta installer didn't. It can be downloaded/run separately from https://www.visualstudio.com/downloads/
if you go there, get the x64 version, download it and run it and let us know if it solves the problem. Official release will definitely run the redistributable for you.
3. You can use the "dependency walker" to drill into the JNI dll to find which dependencies it's missing but likely it's either 1 or 2 above.

Please let me know how it goes,
-Ayman

User avatar
Michael Fanton
Posts: 11
Joined: Sun Jan 22, 2017 12:21 pm

Re: Error configuring MATLAB to work with OpenSim 4.0

Post by Michael Fanton » Fri Apr 13, 2018 10:24 am

Ayman,

Thanks for the quick response, I appreciate the help.

I tried downloading and installing VS 2017 but that did not seem to fix the problem. Regarding your first suggestion, how exactly do I find the wrong/mixed libraries on my path?

Best,
Michael

User avatar
Michael Fanton
Posts: 11
Joined: Sun Jan 22, 2017 12:21 pm

Re: Error configuring MATLAB to work with OpenSim 4.0

Post by Michael Fanton » Fri Apr 13, 2018 10:36 am

I also tried running dependency walker on the JNI dll and got the following message:

"Errors were detected when processing "c:\opensim 4.0.beta\bin\OSIMJAVAJNI.DLL" See log window for details"

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Error configuring MATLAB to work with OpenSim 4.0

Post by Christopher Dembia » Fri Apr 13, 2018 10:46 am

I think Ayman was suggesting you install the Redistributable, not Visual Studio 2017 itself: https://go.microsoft.com/fwlink/?LinkId=746572

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Error configuring MATLAB to work with OpenSim 4.0

Post by Christopher Dembia » Fri Apr 13, 2018 10:47 am

Can you open a Windows command prompt (cmd), type
echo %PATH%
and share the output?

User avatar
Ayman Habib
Posts: 2252
Joined: Fri Apr 01, 2005 12:24 pm

Re: Error configuring MATLAB to work with OpenSim 4.0

Post by Ayman Habib » Fri Apr 13, 2018 10:53 am

Michael,

What messages (usually in red) did you get in dependency walker? That usually indicates which dlls are missing or not on your path, it will also show you the full paths for the libraries it found and you can check if that mixes up 3.3 and 4.0 libraries. And indeed I was suggesting you run the redistributable rather than install VS2017 though the latter would also take care of the problem but is a much bigger task.

One possible issue is that you're using an older Matlab that may have built in dependency on earlier version of VisualStudio.

Let me know how it goes,
-Ayman

User avatar
Michael Fanton
Posts: 11
Joined: Sun Jan 22, 2017 12:21 pm

Re: Error configuring MATLAB to work with OpenSim 4.0

Post by Michael Fanton » Fri Apr 13, 2018 10:54 am

Hi Chris,

You're right, thanks for the clarification, I tried installing the redistributable but I am still getting the same error.

Here is the output from %PATH%:

C:\Users\Michael>echo %PATH%
C:\Anaconda3;C:\Anaconda3\Library\mingw-w64\bin;C:\Anaconda3\Library\usr\bin;C:\Anaconda3\Library\bin;C:\Anaconda3\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\VanDyke Software\Clients\;C:\OpenSim 3.3\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\MIT\Kerberos\bin;C:\MATLAB\R2015b\runtime\win64;C:\MATLAB\R2015b\bin;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program Files (x86)\Cine Viewer;C:\Program Files\OpenAFS\Common;C:\Program Files\OpenAFS\Client\Program;C:\Program Files (x86)\OpenAFS\Common;C:\Program Files (x86)\OpenAFS\Client\Program;C:\Users\Michael\AppData\Local\Microsoft\WindowsApps;

Best,
Michael

User avatar
Michael Fanton
Posts: 11
Joined: Sun Jan 22, 2017 12:21 pm

Re: Error configuring MATLAB to work with OpenSim 4.0

Post by Michael Fanton » Fri Apr 13, 2018 11:02 am

Ayman,

I am getting a number of error messages, saying "error opening file. The system cannot find the file specified (2)"
There are a lot (over 100) of files that it can not open, all under "KERNAL32.dll"

However, I also used the dependency walker on the JNI dll from Opensim 3.3 (which was previously working fine) and I got the same errors.

Best,
Michael

User avatar
Michael Fanton
Posts: 11
Joined: Sun Jan 22, 2017 12:21 pm

Re: Error configuring MATLAB to work with OpenSim 4.0

Post by Michael Fanton » Fri Apr 13, 2018 1:12 pm

Hi Ayman and Chris,

I ended up figuring out what the problem was. I thought I was editing the system Path but instead I was simply adding in an additional system variable. After adding my Opensim 4.0 directory to my path, and making sure that it was before the OpenSim 3.0 directory, it is now working.

Thanks again for all of your help, I appreciate all of the comments and suggestions.

Best,
Michael

POST REPLY