JuliaInterop / MATLAB.jl

Calling MATLAB in Julia through MATLAB Engine
MIT License
270 stars 63 forks source link

Error precompiling MATLAB.jl #191

Closed PaoloVarraso closed 3 years ago

PaoloVarraso commented 3 years ago

Hi,

I am trying to use the MATLAB.jl package on my Mac. The installation seems successful but when I try to use the package I get the following error

julia> using MATLAB [ Info: Precompiling MATLAB [10e44e05-a98a-55b3-a45b-ba969058deb6] ERROR: LoadError: MATLAB is not properly installed. Please run Pkg.build("MATLAB") and restart Julia. Stacktrace: [1] error(::String) at ./error.jl:33 [2] top-level scope at /Users/dp1311/.julia/packages/MATLAB/T20Ly/src/MATLAB.jl:40 [3] include(::Function, ::Module, ::String) at ./Base.jl:380 [4] include(::Module, ::String) at ./Base.jl:368 [5] top-level scope at none:2 [6] eval at ./boot.jl:347 [inlined] [7] eval(::Expr) at ./client.jl:467 [8] top-level scope at ./none:3 in expression starting at /Users/dp1311/.julia/packages/MATLAB/T20Ly/src/MATLAB.jl:37 ERROR: Failed to precompile MATLAB [10e44e05-a98a-55b3-a45b-ba969058deb6] to /Users/dp1311/.julia/compiled/v1.5/MATLAB/6HSOn_F7yJF.ji. Stacktrace: [1] error(::String) at ./error.jl:33 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1305 [3] _require(::Base.PkgId) at ./loading.jl:1030 [4] require(::Base.PkgId) at ./loading.jl:928 [5] require(::Module, ::Symbol) at ./loading.jl:923

I try to build the package but again I get back an error

julia> Pkg.build("MATLAB") Building MATLAB → ~/.julia/packages/MATLAB/T20Ly/deps/build.log ┌ Error: Error building MATLAB: │ [ Info: Detected MATLAB root folder at "/Applications/MATLAB_R2015b.app/bin" │ ERROR: LoadError: could not load library "/Applications/MATLAB_R2015b.app/bin/bin/maci64/libmx" │ dlopen(/Applications/MATLAB_R2015b.app/bin/bin/maci64/libmx.dylib, 1): image not found │ Stacktrace: │ [1] dlopen(::String, ::UInt32; throw_error::Bool) at ``/Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Libdl/src/Libdl.jl:109 │ [2] dlopen at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Libdl/src/Libdl.jl:109 [inlined] (repeats 2 times) │ [3] dlpath(::String) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Libdl/src/Libdl.jl:232 │ [4] top-level scope at /Users/dp1311/.julia/packages/MATLAB/T20Ly/deps/build.jl:70 │ [5] include(::String) at ./client.jl:457 │ [6] top-level scope at none:5 │ in expression starting at /Users/dp1311/.julia/packages/MATLAB/T20Ly/deps/build.jl:67 └ @ Pkg.Operations /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/Operations.jl:949

Is there a way to solve this issue?

Thanks!

musm commented 3 years ago

Have you checked: https://github.com/JuliaInterop/MATLAB.jl#mac-os-x ?

PaoloVarraso commented 3 years ago

Have you checked: https://github.com/JuliaInterop/MATLAB.jl#mac-os-x ?

Yes I checked, but it doesn't help much. The error I get says

Info: Detected MATLAB root folder at "/Applications/MATLAB_R2015b.app/bin

So, I think MATLAB is correctly installed in /Applications

musm commented 3 years ago

I wonder why the image is not found

Applications/MATLAB_R2015b.app/bin/bin/maci64/libmx.dylib

Does libmx exist there or anywhere else?

musm commented 3 years ago

That's a reletively old version of MATLAB, but I don't think they change around library paths that often, so it should be fine.

PaoloVarraso commented 3 years ago

I wonder why the image is not found

Applications/MATLAB_R2015b.app/bin/bin/maci64/libmx.dylib

Does libmx exist there or anywhere else?

I do not know. The problem seems indeed related to libmx

dlopen(/Applications/MATLAB_R2015b.app/bin/bin/maci64/libmx.dylib, 1): image not found

Maybe installing a more recent version of Matlab may help.

PaoloVarraso commented 3 years ago

I downloaded the most recent version of Matlab and the problem was solved. Thanks!

musm commented 3 years ago

Great! I think this is probably an issue with the library files being in a different location than expected on very old MATLAB versions.