OpenSim 4.4 and 4.5 MATLAB API on Apple Silicon M2 (arm64)
Posted: Fri Feb 02, 2024 9:14 am
Hi everyone,
I am trying to configure and set up the OpenSim API in MATLAB on my new MacBook which has an Apple Silicon M2 Pro chip. I am running Matlab R2023b Update 3 (64-bit maca64) and have both OpenSim 4.4 and 4.5 (2024-01-10-3b63585) versions installed. When I run the configureOpenSim.m for either version it susscessfully completes and updates the paths for the OpenSim API with the following message:
Is there a way to circumvent these architecture mismatches, as there is with Conda and Python (e.g., https://simtk-confluence.stanford.edu:8 ... da+Package)? Or will OpenSim support arm64 with a future release?
Many thanks,
Oliver
I am trying to configure and set up the OpenSim API in MATLAB on my new MacBook which has an Apple Silicon M2 Pro chip. I am running Matlab R2023b Update 3 (64-bit maca64) and have both OpenSim 4.4 and 4.5 (2024-01-10-3b63585) versions installed. When I run the configureOpenSim.m for either version it susscessfully completes and updates the paths for the OpenSim API with the following message:
However, when I restart Matlab and try the above line or try to check the version with org.opensim.modeling.opensimCommon.GetVersion() I get the following Matlab error:OpenSim successfully added
Paths have been successfully updated for the OpenSim API installed at /Applications/OpenSIM 4.5-2024-01-10-3b63585/OpenSim 4.5-2024-01-10-3b63585.app/Contents/Resources/OpenSim. To complete setup, restart MATLAB. To test your set u, type: `model = rg.opensim.modelling.Model();`
and then:Error: Failed to load OpenSim libraries
Failed to load one or more dynamic libraries for OpenSim.
java.lang.UnsatisfiedLinkError: /Applications/OpenSim 4.5-2024-01-10-3b63585/OpenSim 4.5-2024-01-10-3b63585.app/Contents/Resources/opensim/sdk/lib/libosimJavaJNI.dylib: dlopen(/Applications/OpenSim 4.5-2024-01-10-3b63585/OpenSim 4.5-2024-01-10-3b63585.app/Contents/Resources/opensim/sdk/lib/libosimJavaJNI.dylib, 0x0001): tried: '/Applications/OpenSim 4.5-2024-01-10-3b63585/OpenSim 4.5-2024-01-10-3b63585.app/Contents/Resources/opensim/sdk/lib/libosimJavaJNI.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Applications/OpenSim 4.5-2024-01-10-3b63585/OpenSim 4.5-2024-01-10-3b63585.app/Contents/Resources/opensim/sdk/lib/libosimJavaJNI.dylib' (no such file), '/Applications/OpenSim 4.5-2024-01-10-3b63585/OpenSim 4.5-2024-01-10-3b63585.app/Contents/Resources/opensim/sdk/lib/libosimJavaJNI.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
I assume the java library architecture mismatch might be causing my issue. x86_64 is the architecture used by OpenSim and arm64 is the architecture on the Apple Silicon chips that my MATLAB runs on, if I am not mistaken. So, MATLAB is looking for the library in the arm64 architecture but can only find the libosimJavaJNI.dylib with a x86_64 architecture, correct?Java exception occurred:
java.lang.UnsatisfiedLinkError: org.opensim.modeling.opensimCommonJNI.swig_module_init()V
at org.opensim.modeling.opensimCommonJNI.swig_module_init(Native Method)
at org.opensim.modeling.opensimCommonJNI.<clinit>(opensimCommonJNI.java:3242)
at org.opensim.modeling.opensimCommon.GetVersion(opensimCommon.java:25)
Is there a way to circumvent these architecture mismatches, as there is with Conda and Python (e.g., https://simtk-confluence.stanford.edu:8 ... da+Package)? Or will OpenSim support arm64 with a future release?
Many thanks,
Oliver