Arch Linux Wayland 安装 MATLAB

Sat, Nov 2, 2024heziahArch LinuxMATLAB

Q1: Unable to launch the MATLABWindow application

the installer crashes as follows:

bash
$ ./install 

terminate called after throwing an instance of 'std::runtime_error'
  what():  Failed to launch web window with error: Unable to launch the MATLABWindow application. The exit code was: 127
[1]    1409378 IOT instruction (core dumped)  ./install

To find out why MATLABWindow is crashing, run it manually to get detailed information.

bash
$ ./bin/glnxa64/MATLABWindow

bin/glnxa64/MATLABWindow: symbol lookup error: /usr/lib/libcairo.so.2: undefined symbol: FT_Get_Color_Glyph_Layer

FT_Get_Color_Glyph_Layer is a symbol of freetype2, which indicates a library incompatibility between the MATLAB application and the Arch Linux packages. [6]

To fix this, put aside MATLAB's libfreetype.so*.

bash
$ rm ./bin/glnxa64/libfreetype.so*

You can also use LD_PRELOAD environment variable to force MATLAB use Arch Linux's libfreetype without removing the lib file.

bash
$ export LD_PRELOAD=/lib64/libfreetype.so
$ ./install

Similarly, if the error is caused by undefined symbol: g_log_structured..., put aside MATLAB's libglib-2.0.so*. If the error is caused by path to/libstdc++.so.6: version CXXABI_1.3.9' not found (required by somelibrary), put aside MATLAB's libstdc++.so.6`.

bash
$ rm ./bin/glnxa64/../../sys/os/glnxa64/libstdc++.so*
$ rm ./bin/glnxa64/libstdc++.so*

Q2: GUI installer is unable to create the target folder when installing as user

Make the folder manually (as root), and take ownership. The path is typically /usr/local/MATLAB

plain
# mkdir -p /path/to/MATLAB/R20XXx
# chown -R $LOGNAME: /path/to/MATLAB/R20XXx

创建符号链接:可以临时sudo chown -R $LOGNAME: /usr/local/bin , 然后 sudo chown -R root:root /usr/local/bin

Q3: 创建 /usr/share/applications/matlab.desktop

bash
[Desktop Entry]
Type=Application
Terminal=false
MimeType=text/x-matlab
Exec=env LD_PRELOAD="/usr/lib64/libfreetype.so.6" /usr/local/MATLAB/R2023a/bin/matlab -desktop -useStartupFolderPref
Name=MATLAB
Icon=matlab
Categories=Development;Math;Science
Comment=Scientific computing environment
StartupNotify=true

Q4: Unable to open this file in the current system configuration.

无法在当前系统配置中打开此文件 问题原因同 Q1

bash
cd <matlab_root>
mv ./bin/glnxa64/libfreetype.so.6 ./bin/glnxa64/libfreetype.so.6.old
mv ./bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6 ./bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6.ol

If you are getting some weird error that does not happen elsewhere, you can find all the external libraries Matlab is linking to by running the following command.

bash
find /usr/local/MATLAB/R2022b -name "*.so*" -exec ldd {} \; 2>/dev/null | grep 'not found' | sort -u | sed -r 's/^\s+(\[S+.so](http://s+.so/)).*$/\1/'

通过以上命令可以检查链接库错误,并针对解决。

Q5: gtk2

bash
pacman -Qi gtk2
sudo pacman -S gtk2

参考链接

https://ww2.mathworks.cn/matlabcentral/answers/1815470-matlab-live-editor-unable-to-open-this-file-in-the-current-system-configuration

https://wiki.archlinux.org/title/MATLAB

https://blog.csdn.net/lxyoucan/article/details/127980952

https://juejin.cn/post/7230860299984273467