UnsatisfiedLinkError using C3DFileAdapter
- Sander Holthof
- Posts: 2
- Joined: Wed Nov 29, 2017 8:15 am
UnsatisfiedLinkError using C3DFileAdapter
Hi,
I'm currently trying to run the C3dexport matlab code (which uses the osimC3D code) to generate trc and mot files from a C3D file. However I keep getting this error:
Error using osimC3D (line 65)
Java exception occurred:
java.lang.UnsatisfiedLinkError: org.opensim.modeling.opensimCommonJNI.new_C3DFileAdapter__SWIG_0()J
at org.opensim.modeling.opensimCommonJNI.new_C3DFileAdapter__SWIG_0(Native Method)
at org.opensim.modeling.C3DFileAdapter.<init>(C3DFileAdapter.java:41)
Error in c3dExport (line 35)
c3d = osimC3D(c3dpath,1);
From what i can tell from google searching this means something must be wrong with my libraries or paths which means matlab can't define the class C3DFileAdapter. However I followed the standard instructions for connecting opensim to matlab and I've checked that the utilities folder is included in the path. Does anyone know what could be causing this?
I'm using Matlab2018 and Opensim 4.0 on Windows 8.1. This is my first post on the forum please let me know if you require any extra information!
Sander
I'm currently trying to run the C3dexport matlab code (which uses the osimC3D code) to generate trc and mot files from a C3D file. However I keep getting this error:
Error using osimC3D (line 65)
Java exception occurred:
java.lang.UnsatisfiedLinkError: org.opensim.modeling.opensimCommonJNI.new_C3DFileAdapter__SWIG_0()J
at org.opensim.modeling.opensimCommonJNI.new_C3DFileAdapter__SWIG_0(Native Method)
at org.opensim.modeling.C3DFileAdapter.<init>(C3DFileAdapter.java:41)
Error in c3dExport (line 35)
c3d = osimC3D(c3dpath,1);
From what i can tell from google searching this means something must be wrong with my libraries or paths which means matlab can't define the class C3DFileAdapter. However I followed the standard instructions for connecting opensim to matlab and I've checked that the utilities folder is included in the path. Does anyone know what could be causing this?
I'm using Matlab2018 and Opensim 4.0 on Windows 8.1. This is my first post on the forum please let me know if you require any extra information!
Sander
Tags:
- Ton van den Bogert
- Posts: 166
- Joined: Thu Apr 27, 2006 11:37 am
Re: UnsatisfiedLinkError using C3DFileAdapter
I have exactly the same error, so I would like to know if there is a known solution .
Using Opensim 4.1 and Matlab 2019b.
Ton van den Bogert
Using Opensim 4.1 and Matlab 2019b.
Ton van den Bogert
- Dimitar Stanev
- Posts: 1096
- Joined: Fri Jan 31, 2014 5:14 am
Re: UnsatisfiedLinkError using C3DFileAdapter
Hi,
Probably, you are using scripts that worked with v4.0 and in v4.1 the API changed. I think that in v4.1, you have to follow a slightly different procedure to read a c3d file (code is in Python):
You can find the scripts that I used attached.
Hope this helps.
Probably, you are using scripts that worked with v4.0 and in v4.1 the API changed. I think that in v4.1, you have to follow a slightly different procedure to read a c3d file (code is in Python):
Code: Select all
adapter = opensim.C3DFileAdapter()
static = adapter.read(os.path.join(c3d_dir, static_file))
Hope this helps.
- Ton van den Bogert
- Posts: 166
- Joined: Thu Apr 27, 2006 11:37 am
Re: UnsatisfiedLinkError using C3DFileAdapter
I am using the osimC3D.m script that came with Opensim 4.1:
The Opensim 4.1/bin folder is in my Windows path, and I have executed the configureOpensim.m script that came with Opensim 4.1.
I even reinstalled Opensim 4.1 from scratch which made no difference.
When I did this with Opensim 4.0, I ran into the same error, which may be a clue.
The error message is a Java exception:
Ton
Code: Select all
>> which osimC3D
C:\Users\Ton\Documents\OpenSim\4.1\Code\Matlab\Utilities\osimC3D.m % osimC3D constructor
I even reinstalled Opensim 4.1 from scratch which made no difference.
When I did this with Opensim 4.0, I ran into the same error, which may be a clue.
The error message is a Java exception:
Code: Select all
Error using osimC3D (line 66)
Java exception occurred:
java.lang.UnsatisfiedLinkError: org.opensim.modeling.opensimCommonJNI.new_C3DFileAdapter__SWIG_0()J
at org.opensim.modeling.opensimCommonJNI.new_C3DFileAdapter__SWIG_0(Native Method)
at org.opensim.modeling.C3DFileAdapter.<init>(C3DFileAdapter.java:41)
- Mohammadreza Rezaie
- Posts: 407
- Joined: Fri Nov 24, 2017 12:48 am
Re: UnsatisfiedLinkError using C3DFileAdapter
Hi,
I think something is wrong with configuration OpenSim in MATLAB.
Re-run the confugireOpensim.m and restart the MATLAB afterward.
Also, when two different versions of OpenSim exist in the system or user environment path, an error appears. Just keep /Opensim 4.1/bin and remove previous versions from those paths.
Hope this helps.
Regards.
I think something is wrong with configuration OpenSim in MATLAB.
Re-run the confugireOpensim.m and restart the MATLAB afterward.
Also, when two different versions of OpenSim exist in the system or user environment path, an error appears. Just keep /Opensim 4.1/bin and remove previous versions from those paths.
Hope this helps.
Regards.
- Dimitar Stanev
- Posts: 1096
- Joined: Fri Jan 31, 2014 5:14 am
Re: UnsatisfiedLinkError using C3DFileAdapter
Hi,
Thanks for letting us know. I was just trying to set up Windows and Matlab to test the script.
About the PATH, this makes sense. For example, if you have used OpenSim v.3.3 and then you install v4.1, the PATH variable may have two entries of the /bin folder. If v3.3 is first in the list, Matlab will try loading the dynamic libraries of v3.3 instead of v4.1.
To avoid this, I use Rapid Environment Editor on Windows. You can have multiple entries in the path with both v3.3 and v4.1. What matters is the order (first in the list). To be sure, you can delete all instances of v3.3 and make sure that you have only v4.1's bin.
Also, note that in Rapid Environment Editor you can edit the system variables and the user variables. When OpenSim is installed it adds into the system's PATH variable. This means that you might append the user PATH variable, but the system's PATH variable will be considered with higher priority.
Thanks for letting us know. I was just trying to set up Windows and Matlab to test the script.
About the PATH, this makes sense. For example, if you have used OpenSim v.3.3 and then you install v4.1, the PATH variable may have two entries of the /bin folder. If v3.3 is first in the list, Matlab will try loading the dynamic libraries of v3.3 instead of v4.1.
To avoid this, I use Rapid Environment Editor on Windows. You can have multiple entries in the path with both v3.3 and v4.1. What matters is the order (first in the list). To be sure, you can delete all instances of v3.3 and make sure that you have only v4.1's bin.
Also, note that in Rapid Environment Editor you can edit the system variables and the user variables. When OpenSim is installed it adds into the system's PATH variable. This means that you might append the user PATH variable, but the system's PATH variable will be considered with higher priority.
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: UnsatisfiedLinkError using C3DFileAdapter
Thanks Dimitar,
By launching OpenSim 4.1 GUI and typing the following in the scripting window:
You'll be able to inspect/write/test code that uses the C3DFileAdapter without worry about path setting or wiring to Matlab and you'll find out if the API has changed, and if changed how.
Past that, the issue boils down to wiring Matlab to the correct version. If you have multiple on your system or you have old settings, our configure script tries to clean things up but is not 100% robust. I believe Dimitar addressed some potential pitfalls. I'd just add that our installer does not modify any path variables since this is not required for the GUI/application's operation, users are asked to do that manually to wire Matlab and/or python.
Please let us know if the issue has been resolved so we know if further investigation is needed.
Best regards,
-Ayman
By launching OpenSim 4.1 GUI and typing the following in the scripting window:
Code: Select all
import org.opensim.modeling as osim
c3d = osim.C3DFileAdapter()
methodsview(c3d)
Past that, the issue boils down to wiring Matlab to the correct version. If you have multiple on your system or you have old settings, our configure script tries to clean things up but is not 100% robust. I believe Dimitar addressed some potential pitfalls. I'd just add that our installer does not modify any path variables since this is not required for the GUI/application's operation, users are asked to do that manually to wire Matlab and/or python.
Please let us know if the issue has been resolved so we know if further investigation is needed.
Best regards,
-Ayman
- Ton van den Bogert
- Posts: 166
- Joined: Thu Apr 27, 2006 11:37 am
Re: UnsatisfiedLinkError using C3DFileAdapter
Thanks for all the hints.
I had Opensim 3.3, 4.0, and 4.1 installed. I had already made sure that only one Opensim /bin folder was in the path.
There was an OPENSIM_HOME environment variable that pointed to Opensim 3.3. After I deleted that one, the Matlab API for Opensim 4.0 was working.
Now my Opensim 3.3 project probably won't work anymore, but I will be able to fix that.
Ton
I had Opensim 3.3, 4.0, and 4.1 installed. I had already made sure that only one Opensim /bin folder was in the path.
There was an OPENSIM_HOME environment variable that pointed to Opensim 3.3. After I deleted that one, the Matlab API for Opensim 4.0 was working.
Now my Opensim 3.3 project probably won't work anymore, but I will be able to fix that.
Ton
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: UnsatisfiedLinkError using C3DFileAdapter
Thanks for the update Ton, much appreciated.
-Ayman
-Ayman