dss-extensions / dss_matlab

MATLAB interface to our alternative implementation of OpenDSS, based on the DSS C-API library aiming for full COM compatibility on Windows, Linux and MacOS.
BSD 3-Clause "New" or "Revised" License
11 stars 2 forks source link

Incompatible architectures with dss_capi.dylib [MacOS Apple Silicon] #19

Closed rsparks3 closed 6 months ago

rsparks3 commented 6 months ago

Hello! I am trying to run the 13Bus example on MacOS (arm64), and I am getting an error. I have the folder containing +DSS_MATLAB added to MATLAB path, and then when I run examples/13Bus/run.m, I get the following error:

Error using loadlibrary
There was an error loading the library
"/Users/rsparks3/Documents/dss_matlab/+DSS_MATLAB/dss_capi.dylib"
dlopen(/Users/rsparks3/Documents/dss_matlab/+DSS_MATLAB/dss_capi.dylib, 0x0006): tried:
'/Users/rsparks3/Documents/dss_matlab/+DSS_MATLAB/dss_capi.dylib' (mach-o file, but is an
incompatible architecture (have 'arm64', need 'x86_64')),
'/System/Volumes/Preboot/Cryptexes/OS/Users/rsparks3/Documents/dss_matlab/+DSS_MATLAB/dss_capi.dylib'
(no such file), '/Users/rsparks3/Documents/dss_matlab/+DSS_MATLAB/dss_capi.dylib' (mach-o file,
but is an incompatible architecture (have 'arm64', need 'x86_64'))

Error in DSS_MATLAB.APIUtil (line 49)
                loadlibrary(DLLfilePath, @DSS_MATLAB.dss_capi_no_thunk);

Error in DSS_MATLAB.IDSS (line 76)
            apiutil = DSS_MATLAB.APIUtil(varargin{:});

Error in run (line 36)
DSS = DSS_MATLAB.IDSS;

Caused by:
    Error using loaddefinedlibrary
    dlopen(/Users/rsparks3/Documents/dss_matlab/+DSS_MATLAB/dss_capi.dylib, 0x0006): tried:
    '/Users/rsparks3/Documents/dss_matlab/+DSS_MATLAB/dss_capi.dylib' (mach-o file, but is an
    incompatible architecture (have 'arm64', need 'x86_64')),
    '/System/Volumes/Preboot/Cryptexes/OS/Users/rsparks3/Documents/dss_matlab/+DSS_MATLAB/dss_capi.dylib'
    (no such file), '/Users/rsparks3/Documents/dss_matlab/+DSS_MATLAB/dss_capi.dylib' (mach-o
    file, but is an incompatible architecture (have 'arm64', need 'x86_64'))

I tried downloading dss_capi v0.14.5 and using the .dylib files from that, but I get the exact same error. I think I have installed opendss properly as I can run opendsscmd in terminal and it will allow me to run DSS commands.

Has anyone seen this error or can point me in the right direction? Thanks a bunch.

PMeira commented 6 months ago

From the error message:

(have 'arm64', need 'x86_64'))

Looks like you're running an Intel x64 installation of MATLAB. In that case, you need to download/use our x64 package instead.

To check, try running this on MATLAB:

archstr = computer('arch')

Per MATLAB's help, it should return one of these:

'maci64' - 64-bit macOS platform 'maca64' - 64-bit macOS platform, Apple silicon

If it returns maci64, you have a x64 MATLAB install, running through Rosetta. As a reminder:

Native Apple silicon MATLAB is available for MATLAB R2023b and up.

If your MATLAB is indeed R2023b and up, try reinstalling MATLAB, ensuring the ARM/Apple Silicon version of the installation is used.

I think I have installed opendss properly as I can run opendsscmd in terminal and it will allow me to run DSS commands.

We don't use or require opendsscmd are all. Currently, I personally don't recommend using opendsscmd outside of Windows since EPRI doesn't support it and there are many known issues on Linux/macOS.

rsparks3 commented 6 months ago

Installing the apple silicon version of matlab worked great! Thank you so much for your help. I'll also get rid of opendsscmd, I had previously installed it thinking it was required for this.