# Error when build MATLAB

**URL:** <https://discourse.julialang.org/t/error-when-build-matlab/92050>\
**Category:** General Usage\
**Tags:** matlab\
**Created:** [December 23, 2022, 2:23pm UTC](https://discourse.julialang.org/t/error-when-build-matlab/92050 "2022-12-23T14:23:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jxpeng98](https://avatars.discourse-cdn.com/v4/letter/j/9d8465/32.png) [@jxpeng98](https://discourse.julialang.org/u/jxpeng98)\
**Post date:** [December 23, 2022, 2:23pm UTC](https://discourse.julialang.org/t/error-when-build-matlab/92050/1 "2022-12-23T14:23:14Z")

</div>

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:

```julia
    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:

```julia
    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?

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [December 23, 2022, 9:46pm UTC](https://discourse.julialang.org/t/error-when-build-matlab/92050/2 "2022-12-23T21:46:23Z")

</div>

Welcome.  
This issue was recently discussed on the forum here: [Using MATLAB Package with R2022b and R2021b downloaded](https://discourse.julialang.org/t/using-matlab-package-with-r2022b-and-r2021b-downloaded/90785)

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.

---

<div class="post-metadata">

**Author:** ![jxpeng98](https://avatars.discourse-cdn.com/v4/letter/j/9d8465/32.png) [@jxpeng98](https://discourse.julialang.org/u/jxpeng98)\
**Post date:** [January 3, 2023, 10:40pm UTC](https://discourse.julialang.org/t/error-when-build-matlab/92050/3 "2023-01-03T22:40:01Z")

</div>

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](https://www.pengjiaxin.com/2023/01/01/matlabengine-applesilicon-julia/).
