MATLAB

出自 Arch Linux 中文维基

引自官方網站:

MATLAB是數百萬工程師和科學家都在使用的編程和數值計算平台,支持數據分析、算法開發和建模。

概覽[編輯 | 編輯原始碼]

MATLAB是MathWorks公司開發的專有軟體。獲取,安裝和激活Matlab需要許可證。MATLAB一年發布兩次新版本,發布名稱由R,發布年份和ab構成。從R2012b開始,只有64位Linux才可使用Matlab。Arch Linux 不受官方支持。參見系統要求

安裝[編輯 | 編輯原始碼]

在安裝 MATLAB 前需要獲取一份完整的軟體副本。對於許可證持有者,MATLAB 軟體可以通過 DVD 或者 MathWorks 網站 獲取。 除了軟體本身,安裝還需要一份文件安裝密鑰。要安裝 MATLAB,你既可以通過 matlabAUR 軟體包也可以直接使用 MATLAB 安裝軟體。通過 matlabAUR 軟體包安裝的優勢是它可以管理依賴和某些微妙的安裝過程,而直接從安裝軟體安裝則可由普通用戶安裝到他們的家目錄從而不需要 root 權限,並且適用於任何版本的 MATLAB (matlabAUR 軟體包只適用於 MATLAB 2010b 及以後的版本).

從 MATLAB 安裝軟體安裝[編輯 | 編輯原始碼]

MATLAB 安裝軟體是獨立的,它不需要任何額外的依賴來靜默安裝。要通過圖形界面安裝, Xorg 圖形顯示是必要的。 Wayland 目前不受支持。安裝過程由 install 腳本處理。你可以以 root 用戶運行此腳本來安裝 MATLAB 到整個系統,或者以你自己運行來僅為你安裝。

MATLAB 2016a 及更早不兼容 ncurses 6,因此你必須安裝 ncurses5-compat-libsAUR 。 要了解更多信息,查看 #啟動時出現段錯誤

在安裝過程中,你會被詢問是否創建符號連結。如果你選擇不創建,你可以手動創建一個 /usr/local/bin 使得 MATALB 更容易從終端啟動:

# ln -s /{MATLAB}/bin/matlab /usr/local/bin

或者你也可以將 MATLAB 的安裝路徑加入 PATH 環境變量。

桌面入口[編輯 | 編輯原始碼]

你可以選擇創建一個 desktop entry。 MATLAB 文件的 MIME 類型是 text/x-matlab.

這樣啟動 matlab

  • -desktop 從而不使用終端。
  • -nosplash 從而取消啟動畫面。

要想讓圖標正確顯示, StartupWMClass 需要在桌面入口中設置。要找到它,執行 xprop | grep WM_CLASS 然後選擇 MATLAB 窗口

桌面入口示例 (將 R2019a 替換為你的 MATLAB 版本):

/usr/share/applications/matlab.desktop
[Desktop Entry]
Version=R2019a
Type=Application
Terminal=false
MimeType=text/x-matlab
Exec=/usr/local/MATLAB/R2019a/bin/matlab -desktop
Name=MATLAB
Icon=matlab
Categories=Development;Math;Science
Comment=Scientific computing environment
StartupNotify=true

若需設置環境變量,可以在 Exec 中預先準備 env。例如, 到系統的 libfreetype:

Exec=env LD_PRELOAD=/usr/lib/libfreetype.so.6 matlab

你可能想要使用系統的 libstdc++.

從 AUR 軟體包安裝[編輯 | 編輯原始碼]

專用 MATLAB 軟體的EULA是有限制的。matlabAUR 被設計成使 MATLAB 和 Arch 集成。 該軟體包應當在目標系統上被編譯,並且應當在安裝後刪除該軟體包和 Pacman 緩存。分發該軟體包顯然違反了EULA。

matlabAUR 默認安裝最新版的64位 MATLAB。也可以安裝更舊的版本,例如 matlab-r2015bAUR[損壞的連結:package not found]matlabAUR 需要在它的安裝路徑中有 MATLAB 安裝軟體和文件密鑰。 要想從 AUR 安裝 MATLAB, 從 AUR 下載 PKGBUILD。下載包含 MATLAB 安裝器的 zip 文件,然後執行以下命令來下載必要文件:

bsdtar xC matlab -f matlab_R2019a_glnxa64.zip
./matlab/install

確保勾選你需要的所有工具包,然後等待下載。不要關閉安裝窗口。你可以這樣找到下載位置:

sudo find /tmp -name "tmw*"

or

cd /tmp
ls | grep tmw

將下載文件合併到安裝器:

rsync -a /tmp/tmwXXXXXXXX/archives matlab

然後打包:

tar -cvf matlab.tar -C matlab/ .

下載 .lic 文件:訪問 你的 Mathworks 帳戶 並點擊你想要使用的許可證號。前往 Install and Activate 標籤,選擇 "Activate to Retrieve License File"。按照指導下載許可證文件並將將其命名為 matlab.lic。另,會顯示文件安裝密鑰 (FIK) -把它複製粘貼進一個空文件,命名為 matlab.fik.

把以上文件複製進包含 PKGBUILD 文件的路徑。然後修改 PKGBUILD 來安裝你需要的工具包,開始安裝:

makepkg -sri

要了解更多細節,參考 PKGBUILD 文件

配置[編輯 | 編輯原始碼]

Java[編輯 | 編輯原始碼]

The MATLAB software is bundled with a JVM and therefore it is not necessary to install Java. The JVM version supported by MATLAB is listed in System Requirements & Platform Availability or simply type version -java in MATLAB. One could set the MATLAB_JAVA environment variable to use custom JVM, for example, to specify the jre8-openjdk JRE, launch MATLAB with:

$ env MATLAB_JAVA=/usr/lib/jvm/java-8-openjdk/jre matlab

OpenGL加速[編輯 | 編輯原始碼]

MATLAB can take advantage of hardware based 2D and 3D OpenGL acceleration. Support for hardware acceleration needs to be configured outside of MATLAB. Appropriate video drivers need to be installed along with the OpenGL utility library glu package. If X11 forwarding is being used, the video drivers need to be installed on both the client and server. To check if MATLAB is making use of hardware based OpenGL acceleration run:

$ matlab -nodesktop -nosplash -r "opengl info; exit" | grep Software

If "software rendering" is not "false", then there is a problem with your hardware acceleration. If this is the case make sure OpenGL is configured correctly on the system. This can be done with the glxinfo program from the mesa-utils package:

$ glxinfo | grep "direct rendering"

If "direct rendering" is not "yes", then there is likely a problem with your system configuration.

If glxinfo works but not matlab, you can try to run:

$ export LD_PRELOAD=/usr/lib/libstdc++.so; export LD_LIBRARY_PATH=/usr/lib/xorg/modules/dri/; matlab -nodesktop -nosplash -r "opengl info; exit" | grep Software

If its works, you can edit Matlab launcher script to add:

export LD_PRELOAD=/usr/lib/libstdc++.so
export LD_LIBRARY_PATH=/usr/lib/xorg/modules/dri/

If you experience a low-level graphics error, you can use a software implementation of OpenGL or use an older driver. According to this entry in the ArchWiki, in Mesa 20.0 the new Iris driver was promoted to be the default for Gen8+. You may disable it and revert to use the old i965 driver by setting the MESA_LOADER_DRIVER_OVERRIDE=i965 environment variable before starting Matlab or any OpenGL application. Alternatively, you can run Matlab with the following command:

$ env MESA_LOADER_DRIVER_OVERRIDE=i965 matlab -desktop

If it works, you can edit the Matlab launcher script to add:

export MESA_LOADER_DRIVER_OVERRIDE=i965

音頻[編輯 | 編輯原始碼]

To confirm that MATLAB is able to use the default soundcard to present sounds run:

$ matlab -nodesktop -nosplash -r "load handel; sound(y, Fs); pause(length(y)/Fs); exit" > /dev/null

This should play an except from Handel's "Hallelujah Chorus." If this fails make sure ALSA is properly configured. This can be done with the speaker-test program from the alsa-utils package from the official repositories:

$ speaker-test

If you do not hear anything, then there is likely a problem with your system configuration.

GPU計算[編輯 | 編輯原始碼]

MATLAB can take advantage of CUDA enabled GPUs to speed up applications. In order to take advantage of a supported GPU install the nvidia, nvidia-utils, ocl-icd, opencl-nvidia, and cuda packages from the official repositories. To check if MATLAB is able to utilize the GPU run:

$ matlab -nodesktop -nosplash -r "x=rand(10, 'single'); g=gpuArray(x); Success=isequal(gather(g), x), exit"  | sed -ne '/Success =/,$p'

安裝額外的編譯器[編輯 | 編輯原始碼]

In order to access the full functionality of MATLAB (e.g., to use Simulink, Builder JA, and MEX-file compilation), supported versions of the gcc, g++, gfortran, and jdk compilers must be installed. Details about the supported compilers for the current release and previous releases are available online. Many of the supported gcc, g++, jdk compiler versions for past MATLAB releases are available from the AUR (e.g., gcc43AUR, gcc44AUR, gcc47AUR, gcc49AURand jdk7AUR), while past versions of the gfortran compilers are not packaged.

To use previous versions of the the gcc, g++, and gfortran compilers with MEX files, edit ${MATLAB}/bin/mexopts.sh and replace all occurrences of CC='gcc' with CC='gcc-4.X', CXX='g++' with CXX='g++-4.X', and FC='gfortran' with FC='gfortran-4.X', where X is the compiler version appropriate for the particular MATLAB release.

注意: Newer versions of Matlab (at least 2017a) does not seem to respect the ${MATLAB}/bin/mexopts.sh customization. Instead it uses ${MATLAB}/bin/glnxa64/mexopts/LANG_glnxa64.xml file.
注意: Though, it's no officially supported, one could still use higher version of compiler, and ignore the warnings.

Matlab的幫助查看器的配置[編輯 | 編輯原始碼]

The help browser uses valuable slots in the dynamic thread vector and causes competition with core functionality provided by libraries like the BLAS that also depend on the dynamic thread vector. The help browser can be configured to use fewer slots in the dynamic thread vector with

>> webutils.htmlrenderer('basic');

This is a persistent change and to reverse it use

>> webutils.htmlrenderer('default');

Garbled Interface[編輯 | 編輯原始碼]

export J2D_D3D=false
export MATLAB_JAVA=/usr/lib/jvm/java-7-openjdk/jre

Serial port access[編輯 | 編輯原始碼]

Matlab uses a bundled rxtx library to access serial ports. The built-in version requires the user to have write access directly to /var/run which is no good idea. The easiest way to fix this properly is to install the java-rxtx package first. Follow the instructions shown while installing this package to get your user into the right groups. Then run the following commands to make Matlab use the system rxtx version:

cd {MATLAB}/java/jarext
mv RXTXcomm.jar RXTXcomm.jar.off
ln -s /usr/share/java/rxtx/RXTXcomm.jar .

cd {MATLAB}/bin/glnx64
mv librxtxSerial.so librxtxSerial.so.off
ln -s /usr/lib/librxtxSerial.so .

HiDPI and 4k[編輯 | 編輯原始碼]

See HiDPI#MATLAB

故障排除[編輯 | 編輯原始碼]

幫助瀏覽器和動態腳本黑屏[編輯 | 編輯原始碼]

安裝 libselinuxAUR.

靜態線程本地存儲錯誤[編輯 | 編輯原始碼]

MATLAB has a number of libraries that have been compiled with static thread local storage (TLS) including the help broswer doc and the BLAS libraries. For example,

>> doc('help');
>> ones(10)*randn(10);
Error using  * 
BLAS loading error:
dlopen: cannot load any more object with static TLS

is related to the bugs:

A more general solution of recompiling glibc has also been suggested. [1]

Matlab在顯示圖像時崩潰[編輯 | 編輯原始碼]

To identify this error, start MATLAB with

LIBGL_DEBUG=verbose matlab

from the terminal and try to collect OpenGL information with opengl info from the MATLAB command prompt. If it crashes again and there is an output line like

libGL error: dlopen /usr/lib/xorg/modules/dri/swrast_dri.so failed 
(/usr/local/MATLAB/R2011b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: 
version `GLIBCXX_3.4.15' not found (required by /usr/lib/xorg/modules/dri/swrast_dri.so))

then the problem is that MATLAB uses its own GNU C++ library, which is an older version than the up-to-date version on your Arch Linux system. Make MATLAB use the current C++ library for your system by

cd /usr/local/MATLAB/R(your release)/sys/os/glnxa64
sudo unlink libstdc++.so.6
sudo ln -s /usr/lib/libstdc++.so.6

If MATLAB still crashes or corrupts graphics (during startup or when plotting), make sure Java's 2D OpenGL rendering is disabled. The environment variable _JAVA_OPTIONS should not contain -Dsun.java2d.opengl=true.

Blank/grey UI when using WM (non-reparenting window manager)[編輯 | 編輯原始碼]

This is a common issue in a number of window managers. (DWM, Awesome, bspwm) Java does not play well with these window managers. There are two methods.

First try setting the environment variable by running

$ export _JAVA_AWT_WM_NONREPARENTING=1

If Matlab works afterwards, export the variable in your .xinitrc.

If it does not resolve, you have to fool Java into thinking the WM is named LG3D. (It's an old, depreciated WM that Java applications ironically support) Clean the previous environment variable, install the wmname utility, and run.

wmname LG3D

Try running Matlab. If it works, put the fix in your starting script. (.xinitrc, bspwmrc and similar should be OK) Do note that other applications (such as neofetch, or tdrop) will think your WM is named LG3D, so you will have to configure them accordingly. Another solution is to run the command only before launching Matlab, and fixing the name after you are done with Matlab.

If it does not work, try the combination of both. (The second line works in bspwm) If it still does not work, try googling similar issues with java in general.

文本亂碼或不可見[編輯 | 編輯原始碼]

Set the environment variable J2D_D3D to false[2].

In newer versions of MATLAB (R2015b) [3] this also requires setting MATLAB_JAVA to something openjdk based. Example:

export J2D_D3D=false
./bin/glnxa64/install_unix -javadir /usr/lib/jvm/java-7-openjdk/jre

菜單和輸入窗口的文字顯示異常[編輯 | 編輯原始碼]

If you notice that the menus or the input fields are corrupted or not appearing correctly then you can try to activate the "Use antialiasing to smooth desktop fonts" option in Matlab preferences, it seems to solve the problem. Go to Preferences -> Matlab -> Fonts and activate it. You will need to restart Matlab in order to take affect.

安裝依賴缺失[編輯 | 編輯原始碼]

As one installs Matlab, it might complain that it cannot find a package, for the most part just look at the package name and then install it with Pacman, or in the case of x86_64 there are some libraries only in AUR.

Installation error: archive is not a ZIP archive[編輯 | 編輯原始碼]

During the installation you can get:

The following error was detected while installing package_name: archive is not a ZIP archive 
Would you like to retry installing package_name? If you press No, the installer will exit without completing the installation. More information can be found at /tmp/mathworks_root.log

Matlab downloads all packages to /tmp/ directory which resides in RAM and is maximum size of half of available memory. In this case it is not enough for installation files and Matlab 2019a installer will warn you about this. If it did not, or if you ignored the warning, you will have got the above error.

You can either resize tmpfs (3,5 GB is not enough, 6 GB works), or remove packages from base install and add them later with built-in Matlab add-on installer.

安裝時library錯誤[編輯 | 編輯原始碼]

  • Make sure that the symlink bin/glnx64/libstdc++.so.6 is pointing to the correct version of libstdc++.so.xx (which is also in the same directory and has numbers where 'xx' is). By default, it may be pointing to an older (and nonexistent) version (different value for 'xx').
  • Make sure the device you are installing from is not mounted as noexec
  • If you downloaded the files from Mathworks' website, make sure they are not on an NTFS or FAT partition, because that can mess up the symlinks. Ext4 or Ext3 should work.

啟動時出現段錯誤[編輯 | 編輯原始碼]

If Matlab (R2016a or earlier) stops working after upgrading ncurses to v6.x, 安裝 the ncurses5-compat-libsAUR package. See BBS#202575.

In newer versions (e.g. R2017b), the issue could also be due to a font display failing to load. Try moving the libfreetype.so.6 font display file in $MATLAB/bin/glnxa64/ to an 'exclude' directory; see BBS#231299.

與Intel顯卡有關的錯誤[編輯 | 編輯原始碼]

Some users have reported issues with DRI3 enabled on Intel Graphics chips. A possible workaround is to disable DRI3 and run MATLAB with hardware rendering on DRI2; to do so, launch MATLAB with the environment variable LIBGL_DRI3_DISABLE set to 1:

LIBGL_DRI3_DISABLE=1 /{MATLAB}/bin/matlab

If the previous workaround does not work, the issue can be circumvented by selecting software rendering with the MATLAB command (beware, performance may be very poor when doing e.g. big or complex 3D plots):

opengl('save','software')

See [4] and [5] for more.

附加組件管理器無法使用[編輯 | 編輯原始碼]

Addon manager requires the libselinuxAUR package to work. (in Matlab 2017b)

Since upgrade from pango-1.40.5 to pango-1.40.6, the MATLABWindow application (responsible for Add-On Manager, Simulation Data Inspector and perhaps something else) cannot be started. FS#54257 A workaround is to point MATLAB shipping glib libraries to those glib libraries from your system. There are 5 of those libraries in matlabroot/R2017b/cefclient/sys/os/glnxa64, namely, as of R2017b:

libgio-2.0.so
libglib-2.0.so
libgmodule-2.0.so
libgobject-2.0.so
libgthread-2.0.so

Make it so that these symlinks are pointing to your system glib libraries instead of versions located in matlabroot/R2017b/cefclient/sys/os/glnxa64. On a standard arch install the local files reside in /usr/lib/.

Relinking of "libfreetype.so.6" is also necessary to open these interfaces. This is found in matlabroot/R2017b/bin/glnxa64/.

If the window opens but is blank, consider switching the html renderer to: " webutils.htmlrenderer('basic');" as described in #Matlab的幫助查看器的配置.

LiveScript錯誤[編輯 | 編輯原始碼]

If you get the error when attempting to load or create a LiveScript:

 Viewing matlab live script files is not currently supported by this operating system configuration

The steps in #附加組件管理器無法使用 may resolve the issue.

Using webcam/video device[編輯 | 編輯原始碼]

Make sure the correct support package addons are installed (webcam or OS Generic Video Interface for example). If running matlab as a user, make sure your user has write permissions to wherever the support packages are being downloaded and installed.

At least Matlab 2016b does not recognize webcams or imaq adapters correctly without gstreamer0.10. The gstreamer0.10 can be found in the aur and installed as a work around.

Since MATLAB R2017a, Image Acqusition Toolbox is using GStreamer library version 1.0. It previously used version 0.10.

In general, USB Webcam Support Package does a better job working with UVC and built-in cameras than OS Generic Video Interface Support Package.

Warning: As of 2018-08-15 updating gst from 1.14.0 to 1.14.2 breaks video device operation (MATLAB does not see the video device anymore). Downgrading fixes this.

關閉幫助窗口時Matlab數秒無響應[編輯 | 編輯原始碼]

Since upgrade of glibc from 2.24 to 2.25, MATLAB (at least R2017a) hangs when closing Help Browser. The issue is related to the particular version of jxbrowser-chromium shipped with MATLAB. This issue is still present with glibc 2.26 and MATLAB R2017b.

To fix this issue, download the latest jxbrowser and replace the following jars from MATLAB:

matlabroot/java/jarext/jxbrowser-chromium/jxbrowser-chromium.jar
matlabroot/java/jarext/jxbrowser-chromium/jxbrowser-linux64.jar

MATLAB should automatically unpack those jars into matlabroot/sys/jxbrowser-chromium/glnxa64/chromium when first opening Help Browser. Remove matlabroot/sys/jxbrowser-chromium/glnxa64/chromium directory to make sure MATLAB uses the latest jxbrowser.

Unfortunately, this workaround does not work in R2017b anymore. Going deeper into investigation of this issue, it is related to a crash of one of jxbrowser-chromium processes. The parent process of jxbrowser-chromium then sits there and waits for response from a process that is already dead. This causes MATLAB main window to freeze. You can easily unfreeze MATLAB by manually killing all leftover jxbrowser-chromium processes.

I have come up with this simple script that uses inotify and waits for user to close Help browser in MATLAB. It triggers when user closes Help browser and sends kill signal to all leftover jxbrowser-chromium processes:

#!/bin/sh

if [ -z "$1" ]; then
	REL=R2017b
else
	REL=$1
fi

JXPATH="/path/to/MATLAB/$REL/sys/jxbrowser-chromium/glnxa64/chromium"
CMD="inotifywait -m -e CLOSE $JXPATH/resources.pak"

#Exit if the daemon is already active
if ! pgrep -f "$CMD" > /dev/null; then
	#Wait for user to close Help Browser, then killall leftover jxbrowser processes
	$CMD |
	while read line
	do
		killall "$JXPATH/jxbrowser-chromium"
	done
else
	exit
fi

I run this script as part of my MATLAB start script like that:

~/bin/unfreeze_matlab.sh R2017b &

To make sure that this background job is killed when I exit MATLAB, I use this in the beginning of MATLAB start script:

trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT

一些下拉菜單無法被選中[編輯 | 編輯原始碼]

In some interfaces - such as Simulation Data Inspector or Simulink Test Manager - nothing happens when choosing an item in dropdown menu (for example, when trying to change a number of subplots in Simulation Data Inspector). To work around this issue, hold down the Shift key while clicking the item in dropdown menu.

因許可證問題造成的無法啟動Matlab[編輯 | 編輯原始碼]

In case MATLAB will not start from a desktop environment by the call of its desktop file one should see the output as you start it from the terminal. For a Licensing error such as:

# matlab
MATLAB is selecting SOFTWARE OPENGL rendering.
License checkout failed.
License Manager Error -9
This error may occur when: 
-The hostid of this computer does not match the hostid in the license file. 
-A Designated Computer installation is in use by another user. 
If no other user is currently running MATLAB, you may need to activate.

Troubleshoot this issue by visiting: 
https://www.mathworks.com/support/lme/R2017a/9

Diagnostic Information:
Feature: MATLAB 
License path: /home/<USER>/.matlab/R2017a_licenses/license_<NUM>_R2017a.lic:/home/<USER>/.matlab/R2017a_licenses/lice
nse_Darkness_<NUM>_R2017a.lic:/opt/MATLAB/R2017a/licenses/license.dat:/opt/MATLAB/R2017a/licenses/*
.lic 
Licensing error: -9,57.

a re-activation might solve the problem.

啟動Matlab時顯示"Failure loading desktop class"並崩潰[編輯 | 編輯原始碼]

In case MATLAB will not start and starting it from command line gives you the following error:

$ matlab
Fatal Internal Error: Internal Error: Failure occurs during desktop startup. Details: Failure loading desktop class.

and you have the option -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel set in your _JAVA_OPTIONS environment variable, start MATLAB with

$ _JAVA_OPTIONS= matlab

If this works, add the line

export _JAVA_OPTIONS=

to your MATLAB launcher script. Optionally re-add other Java options.

Unable to type in text fields of interfaces based on MATLABWindow[編輯 | 編輯原始碼]

Since R2018a, it is not possible to type text in interfaces based on MATLABWindow - like Signal Editor, Add-Ons Explorer and others. MATLABWindow and MATLAB's webwindow infrastructure is based on Chromium Embedded Framework, and it looks like a known and long standing bug: https://bitbucket.org/chromiumembedded/cef/issues/2026/multiple-major-keyboard-focus-issues-on

One possible workaround is to switch focus from the MATLABWindow to another window and then switch back - so that you can type.

To elaborate more on this workaround (since the problem is still there in R2018b), here is what i did in my Openbox config (note that the A-Middle keybinding already exist in default config):

    <mousebind button="A-Middle" action="Press">
       <action name="Unfocus"/>
       <action name="Focus"/>
     </mousebind>

Now, whenever it is not possible to type in a text field, I press Alt+Mouse middle mouse and then I can type again.

安裝程序顯示 "Unable to launch the MATLABWindow application" 並崩潰[編輯 | 編輯原始碼]

In MATLAB version R2018b (and later), the installer crashes as follows:

 $ ./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.

 $ ./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*.

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

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

$ 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.

Add-on manager does not start in R2020a[編輯 | 編輯原始碼]

In MATLAB version R2020a Update 5 (and possibly older), the Add-on manager does not start. Instead, the following error is shown

 Error using matlab.internal.cef.webwindow (line 385)
 MATLABWindow application failed to launch. Unable to launch the MATLABWindow application
 
 Error in matlab.internal.webwindow/createImplementation (line 288)
                 implObj = matlab.internal.cef.webwindow(varargin{:});
 
 Error in matlab.internal.webwindow (line 144)
             obj.impl = obj.createImplementation(varargin{:});
 
 Error in matlab.internal.addons.AddOnsWindow/launch (line 51)
                 obj.webwindow = matlab.internal.webwindow(char(url), obj.debugPort, obj.normalWindowPosition);
 
 Error in matlab.internal.addons.Explorer/loadUrlForNavigateToMessage (line 125)
                 obj.addOnsWindowInstance.launch(url, obj.windowStateUtil.getExplorerWindowMaximizedSetting);
 
 Error in matlab.internal.addons.Explorer/show (line 56)
                 obj.loadUrlForNavigateToMessage(url);
 
 Error in matlab.internal.addons.launchers.showExplorer (line 128)
         matlab.internal.addons.Explorer.getInstance.show(navigationData);

The problem is solved by removing (or hiding) the libgl* and libgio* libraries of MATLAB, as suggested for an older issue [7]

$ cd {MATLAB INSALLATION FOLDER}/cefclient/sys/os/glnxa64/
$ mkdir exclude
$ mv libglib-2.0.so* libgio-2.0.so* exclude/

在systemd-nspawn容器中運行[編輯 | 編輯原始碼]

Matlab can be run within a systemd-nspawn container to maintain a static system and avoid the library issues that often plague matlab installs after significant updates to libraries in Arch. Refer to Systemd-nspawn for detailed information on setting up such containers.

The following lists instruction to get a MATLAB 2017b install running in a minimal debian 9 environment. It assumes matlab is already installed as normal in "/usr/local/MATLAB/R2017b".

Use Xhost to allow the nspawn environment to use the existing X server instance.

Create a minimal debian environment in a folder ("deb9" here) with:

$ debootstrap --arch=amd64 stretch deb9

Set a password for the root user and then boot the environment with:

$ systemd-nspawn --bind-ro=/dev/dri --bind=/tmp/.X11-unix --bind=/usr/local/MATLAB/ -b -D deb9

Install the following packages to have the requisite libraries in the nspawn environment for MATLAB. "mesa-utils" and "usbutils" can be installed to debug graphics acceleration and usb interfaces for I/O with MATLAB.

$ apt-get install xorg build-essential libgtk2.0-0 libnss3 libasound2 

Install the MATLAB-support (from contrib source) package in the environment for some convenient integration.

$ apt-get install matlab-support

Set the $DISPLAY variable to use your existing X server instance.

$ export DISPLAY=:0

MATLAB can be launched from within the environment normally by using the binary at $MATLABROOT/bin.