opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
797 stars 322 forks source link

Java link error in MATLAB for artifact #3917

Open mattpetrucci opened 1 month ago

mattpetrucci commented 1 month ago

Artifact number: opensim-core-4.5.1-2024-08-23-cf3ef35

When creating a model I receive this error:

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:840)
aymanhab commented 1 month ago

@mattpetrucci For context, this is downloading artifact from ci rather than a released public distribution, is that correct? Any pointer to when did this break or work in the past? Thank you

mattpetrucci commented 1 month ago

@aymanhab correct this is an artifact from CI. Unfortunately I don't have the exact artifact I was using before, but it was back in May 2024.

Also note, we got to this error after manually updating the mumps path (see issue 3916).

carmichaelong commented 1 month ago

@aymanhab Yes this is for downloading an artifact. I went as far back as I could in GitHub Actions, but many artifacts are expired. Furthest I could go back was action 4287, which was 2024-08-09-3fa052e. When loading a model, you get the following error about loading libraries:

Failed to load one or more dynamic libraries for OpenSim.
java.lang.UnsatisfiedLinkError: /Users/carmichaelong/Downloads/opensim-core-4.5.1-2024-08-09-3fa052e/sdk/lib/libosimJavaJNI.dylib: dlopen(/Users/carmichaelong/Downloads/opensim-core-4.5.1-2024-08-09-3fa052e/sdk/lib/libosimJavaJNI.dylib, 0x0001): Library not loaded: /Users/runner/opensim_dependencies_install/mumps/lib/libcoinmumps.3.dylib
  Referenced from: <AF1BB9D6-B360-3CAD-8B1F-BDF43E95FFA7> /Users/carmichaelong/Downloads/opensim-core-4.5.1-2024-08-09-3fa052e/sdk/lib/libipopt.3.dylib
  Reason: tried: '/Users/runner/opensim_dependencies_install/mumps/lib/libcoinmumps.3.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/runner/opensim_dependencies_install/mumps/lib/libcoinmumps.3.dylib' (no such file), '/Users/runner/opensim_dependencies_install/mumps/lib/libcoinmumps.3.dylib' (no such file), '/usr/local/lib/libcoinmumps.3.dylib' (no such file), '/usr/lib/libcoinmumps.3.dylib' (no such file, not in dyld cache)

It's probably some sort of rpath issue? I'll also see what the last working artifact I might have lying around is, but likely it'll be pretty far back so may not help too much to find the specific commit.

carmichaelong commented 1 month ago

@aymanhab This is pretty coarse, but as close as I can get.

Most recent working version for me: OpenSim 4.5 release Oldest artifact that doesn't work for me: 4.5-2024-06-28-6f6fee0

aymanhab commented 1 month ago

If rpath then this can be fixed by setting DYLIB_LIBRARY_PATH as a workaround. Does that work?

nickbianco commented 1 month ago

For Matt, setting DYLD_LIBRARY_PATH manually resolves the issue at #3916, but not this one.

I encounter this error on Windows (artifact opensim-core-4.5.1-2024-09-12-bd17674), but I do not encounter the error at #3916 (probably becuase you have to set the PATH manually on Windows).

aymanhab commented 1 month ago

What I don't understand is that all the moco related libraries should not be loaded or attempted to be loaded when loading/constructing a model (if the stacktrace on top is correct).

carmichaelong commented 1 month ago

Oops, that's my bad. The link error I put here should have been in #3916, not in this one. Sorry for the confusion.

If I'm reading these errors correctly, seems like there's a link issue with opensimSimulation when loading the model, even with the fix with DYLD_LIBRARY_PATH (which resolves the first issue in #3916)

mattpetrucci commented 1 month ago

Yes to confirm the commands were:

import org.opensim.modeling.*;
m = Model();