JuliaInterop / MATLAB.jl

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

libmx error when building #194

Closed yakir12 closed 2 years ago

yakir12 commented 2 years ago

I've just installed matlab 2020b (tested it as well), and when I try to build MATLAB.jl I get an error about not finding libmx:

(jl_lXzwOn) pkg> build MATLAB
    Building MATLAB → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/9edb97bacd74c960b27d6fd230e139689fdc4a7b/build.log`
ERROR: Error building `MATLAB`: 
[ Info: Detected MATLAB root folder at "/usr/local"
[ Info: Detected MATLAB executable at "/usr/local/bin/matlab"
ERROR: LoadError: could not load library "/usr/local/bin/glnxa64/libmx"
/usr/local/bin/glnxa64/libmx.so: cannot open shared object file: No such file or directory
Stacktrace:
 [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
   @ Base.Libc.Libdl ./libdl.jl:117
 [2] dlopen (repeats 2 times)
   @ ./libdl.jl:117 [inlined]
 [3] dlpath(libname::String)
   @ Base.Libc.Libdl ./libdl.jl:240
 [4] top-level scope
   @ ~/.julia/packages/MATLAB/T20Ly/deps/build.jl:70
 [5] include(fname::String)
   @ Base.MainInclude ./client.jl:451
 [6] top-level scope
   @ none:5
in expression starting at /home/yakir/.julia/packages/MATLAB/T20Ly/deps/build.jl:67

I'm on:

julia> versioninfo()
Julia Version 1.7.0-rc3
Commit 3348de4ea6 (2021-11-15 08:22 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
yakir12 commented 2 years ago

Bump.

I've since then upgraded Julia:

julia> versioninfo()

Julia Version 1.7.1
Commit ac5cc99908* (2021-12-22 19:35 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.0 (ORCJIT, skylake)
musm commented 2 years ago

Thanks for the error report. I'll take a look at this later this week to see if there's a fix.

musm commented 2 years ago

Could you dig around your folders to try to find a libmx library? Basically it looks like this library is not where we expect it to live ERROR: LoadError: could not load library "/usr/local/bin/glnxa64/libmx"

yakir12 commented 2 years ago

I found these:

find / -name libmx*
/usr/lib/libmxml.so.1
/usr/lib/libmxml.so
/usr/lib/libmxml.so.1.6
/usr/local/MATLAB/R2020b/bin/glnxa64/libmx.so
find: ‘/run/user/1000/doc’: Permission denied
find: ‘/run/user/1000/gvfs’: Permission denied

So I tried

rm /usr/local/MATLAB/R2020b/bin/glnxa64/libmx.so
ln -s /usr/lib/libmxml.so /usr/local/MATLAB/R2020b/bin/glnxa64/libmx.so

but now matlab doesn't start, and I have the same error when trying to build MATLAB.jl (libmx missing).

musm commented 2 years ago

You'll have to re-run build in Julia if you make those changes.

Have you tried to explicitly set the "MATLAB_ROOT" environment variable to your matlab path /usr/local/MATLAB/R2020b then rerun the build process?

musm commented 2 years ago

If you look at this function https://github.com/JuliaInterop/MATLAB.jl/blob/master/deps/build.jl#L5 we actually don't check usr/local on linux systems. This is probably something I should add after we confirm the manual method above works with you.

yakir12 commented 2 years ago

explicitly set the "MATLAB_ROOT" environment variable

fixed it! So yeah, adding usr/local might be a good idea. I'll happily test it once you're merged.