FreeBSD 使用手冊
前一頁 | 章 10. 與 Linux Binary 的相容方面 | 下一頁

# 10.5. Installing MATLAB®

Contributed by Dan Pelleg.

This document describes the process of installing the Linux version of MATLAB® version 6.5 onto a FreeBSD system. It works quite well, with the exception of the Java Virtual Machine™ (see µÚ 10.5.3 節).

The Linux version of MATLAB can be ordered directly from The MathWorks at http://www.mathworks.com. Make sure you also get the license file or instructions how to create it. While you are there, let them know you would like a native FreeBSD version of their software.

## 10.5.1. Installing MATLAB

To install MATLAB, do the following:

1. Insert the installation CD and mount it. Become `root`, as recommended by the installation script. To start the installation script type:

       # /compat/linux/bin/sh /cdrom/install

   > 提示: The installer is graphical. If you get errors about not being able to open a display, type `setenv HOME ~`USER``, where `USER` is the user you did a su(1) as.

2. When asked for the MATLAB root directory, type: `/compat/linux/usr/local/matlab`.

   > 提示: For easier typing on the rest of the installation process, type this at your shell prompt: `set MATLAB=/compat/linux/usr/local/matlab`

3. Edit the license file as instructed when obtaining the MATLAB license.

   > 提示: You can prepare this file in advance using your favorite editor, and copy it to `$MATLAB/license.dat` before the installer asks you to edit it.

4. Complete the installation process.

At this point your MATLAB installation is complete. The following steps apply “glue” to connect it to your FreeBSD system.

## 10.5.2. License Manager Startup

1. Create symlinks for the license manager scripts:

       # ln -s $MATLAB/etc/lmboot /usr/local/etc/lmboot_TMW
       # ln -s $MATLAB/etc/lmdown /usr/local/etc/lmdown_TMW

2. Create a startup file at `/usr/local/etc/rc.d/flexlm.sh`. The example below is a modified version of the distributed `$MATLAB/etc/rc.lm.glnx86`. The changes are file locations, and startup of the license manager under Linux emulation.

       #!/bin/sh
       case "$1" in
         start)
               if [ -f /usr/local/etc/lmboot_TMW ]; then
                     /compat/linux/bin/sh /usr/local/etc/lmboot_TMW -u username && echo 'MATLAB_lmgrd'
               fi
               ;;
         stop)
       	if [ -f /usr/local/etc/lmdown_TMW ]; then
                   /compat/linux/bin/sh /usr/local/etc/lmdown_TMW  > /dev/null 2>&1
       	fi
               ;;
         *)
       	echo "Usage: $0 {start|stop}"
       	exit 1
       	;;
       esac

       exit 0

   > 重要: The file must be made executable:

   >     # chmod +x /usr/local/etc/rc.d/flexlm.sh

   > You must also replace `username` above with the name of a valid user on your system (and not `root`).

3. Start the license manager with the command:

       # /usr/local/etc/rc.d/flexlm.sh start

## 10.5.3. Linking the Java™ Runtime Environment

Change the Java™ Runtime Environment (JRE) link to one working under FreeBSD:

    # cd $MATLAB/sys/java/jre/glnx86/
    # unlink jre; ln -s ./jre1.1.8 ./jre

## 10.5.4. Creating a MATLAB Startup Script

1. Place the following startup script in `/usr/local/bin/matlab`:

       #!/bin/sh
       /compat/linux/bin/sh /compat/linux/usr/local/matlab/bin/matlab "$@"

2. Then type the command `chmod +x /usr/local/bin/matlab`.

> 提示: Depending on your version of `emulators/linux_base`, you may run into errors when running this script. To avoid that, edit the file `/compat/linux/usr/local/matlab/bin/matlab`, and change the line that says:

>     if [ `expr "$lscmd" : '.*->.*'` -ne 0 ]; then

> (in version 13.0.1 it is on line 410) to this line:

>     if test -L $newbase; then

## 10.5.5. Creating a MATLAB Shutdown Script

The following is needed to solve a problem with MATLAB not exiting correctly.

1. Create a file `$MATLAB/toolbox/local/finish.m`, and in it put the single line:

       ! $MATLAB/bin/finish.sh

   > 注: The `$MATLAB` is literal.

   > 提示: In the same directory, you will find the files `finishsav.m` and `finishdlg.m`, which let you save your workspace before quitting. If you use either of them, insert the line above immediately after the `save` command.

2. Create a file `$MATLAB/bin/finish.sh`, which will contain the following:

       #!/usr/compat/linux/bin/sh
       (sleep 5; killall -1 matlab_helper) &
       exit 0

3. Make the file executable:

       # chmod +x $MATLAB/bin/finish.sh

## 10.5.6. Using MATLAB

At this point you are ready to type `matlab` and start using it.

前一頁 | 內容 | 下一頁
Installing Maple™ | 上一層 | Installing Oracle®

本文及其他文件，可由此下載：ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/。

若有 FreeBSD 方面疑問，請先閱讀 FreeBSD 相關文件，如不能解決的話，再洽詢 <questions@FreeBSD.org>。
關於本文件的問題，請洽詢 <doc@FreeBSD.org>。