Error when build MATLAB

Hello everyone,

I use MacBook Pro M1 Max with macOS 13.2.

When I try to add the package with MATLAB R2022b. I will get the error:

    Building MATLAB → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/e263657fe013cb02450c5d4210d2c50a354a5e08/build.log`
ERROR: Error building `MATLAB`:
[ Info: Detected MATLAB root folder at "/Applications/MATLAB_R2022b.app"
[ Info: Detected MATLAB library path at "/Applications/MATLAB_R2022b.app/bin/maci64"
[ Info: Detected MATLAB executable at "/Applications/MATLAB_R2022b.app/bin/matlab"
ERROR: LoadError: could not load library "/Applications/MATLAB_R2022b.app/bin/maci64/libmx"
dlopen(/Applications/MATLAB_R2022b.app/bin/maci64/libmx.dylib, 0x0001): tried: '/Applications/MATLAB_R2022b.app/bin/maci64/libmx.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Applications/MATLAB_R2022b.app/bin/maci64/libmx.dylib' (no such file), '/Applications/MATLAB_R2022b.app/bin/maci64/libmx.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
Stacktrace:
 [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
   @ Base.Libc.Libdl ./libdl.jl:117
 [2] dlopen (repeats 2 times)
   @ ./libdl.jl:116 [inlined]
 [3] dlpath(libname::String)
   @ Base.Libc.Libdl ./libdl.jl:240
 [4] top-level scope
   @ ~/.julia/packages/MATLAB/SVjnA/deps/build.jl:79
 [5] include(fname::String)
   @ Base.MainInclude ./client.jl:476
 [6] top-level scope
   @ none:5

Recently, I install the MATLAB R2022b native apple silicon version.
When I build MATLAB , the output is:

    Building MATLAB → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/e263657fe013cb02450c5d4210d2c50a354a5e08/build.log`
ERROR: Error building `MATLAB`:
[ Info: Detected MATLAB root folder at "/Applications/MATLAB_R2022b_Beta.app"
[ Info: Detected MATLAB executable at "/Applications/MATLAB_R2022b_Beta.app/bin/matlab"
ERROR: LoadError: could not load library "/Applications/MATLAB_R2022b_Beta.app/bin/maci64/libmx"
dlopen(/Applications/MATLAB_R2022b_Beta.app/bin/maci64/libmx.dylib, 0x0001): tried: '/Applications/MATLAB_R2022b_Beta.app/bin/maci64/libmx.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/MATLAB_R2022b_Beta.app/bin/maci64/libmx.dylib' (no such file), '/Applications/MATLAB_R2022b_Beta.app/bin/maci64/libmx.dylib' (no such file)
Stacktrace:
 [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
   @ Base.Libc.Libdl ./libdl.jl:117
 [2] dlopen (repeats 2 times)
   @ ./libdl.jl:116 [inlined]
 [3] dlpath(libname::String)
   @ Base.Libc.Libdl ./libdl.jl:240
 [4] top-level scope
   @ ~/.julia/packages/MATLAB/SVjnA/deps/build.jl:79
 [5] include(fname::String)
   @ Base.MainInclude ./client.jl:476
 [6] top-level scope
   @ none:5

Is there any solution to fix this error?

Welcome.
This issue was recently discussed on the forum here: Using MATLAB Package with R2022b and R2021b downloaded

Have a look at the README on the Matlab.jl GitHub page. You may need to use version R2021, and a Julia installation, using Rosetta.

Hi,

Many thanks for your reply.

Yes, the problem is the arm64 architecture. It is annoying.

Finally, I run both MATLAB R2021b and Julia 1.8.3 via Rosetta on arch x86_64, and I succeed. There is no issue.

I wrote down the procedure on my blog.

1 Like