3 ## 22.5 Installing MATLAB®
\r
5 ***Contributed by Dan Pelleg. ***
\r
7 This document describes the process of installing the Linux version of **MATLAB® version 6.5** onto a DragonFly system. It works quite well, with the exception of the **Java Virtual Machine™** (see [linuxemu-matlab.html#MATLAB-JRE Section 22.5.3]).
\r
9 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 DragonFly version of their software.
\r
11 ### 22.5.1 Installing MATLAB
\r
13 To install **MATLAB** , do the following:
\r
15 1. Insert the installation CD and mount it. Become `root`, as recommended by the installation script. To start the installation script type:
\r
17 # /compat/linux/bin/sh /cdrom/install
\r
19 **Tip:** 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)](http://leaf.dragonflybsd.org/cgi/web-man?command#su§ion1) as.
\r
20 1. When asked for the **MATLAB** root directory, type: /compat/linux/usr/local/matlab.
\r
21 **Tip:** For easier typing on the rest of the installation process, type this at your shell prompt: `set MATLAB=/compat/linux/usr/local/matlab`
\r
22 1. Edit the license file as instructed when obtaining the **MATLAB** license.
\r
23 **Tip:** 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.
\r
24 1. Complete the installation process.
\r
26 At this point your **MATLAB** installation is complete. The following steps apply ***glue*** to connect it to your DragonFly system.
\r
28 ### 22.5.2 License Manager Startup
\r
30 1. Create symlinks for the license manager scripts:
\r
32 # ln -s $MATLAB/etc/lmboot /usr/local/etc/lmboot_TMW
\r
33 # ln -s $MATLAB/etc/lmdown /usr/local/etc/lmdown_TMW
\r
35 1. 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.
\r
40 if [ -f /usr/local/etc/lmboot_TMW ]; then
\r
41 /compat/linux/bin/sh /usr/local/etc/lmboot_TMW -u `***username***` && echo 'MATLAB_lmgrd'
\r
45 if [ -f /usr/local/etc/lmdown_TMW ]; then
\r
46 /compat/linux/bin/sh /usr/local/etc/lmdown_TMW > /dev/null 2>&1
\r
51 echo "Usage: $0 {start|stop}"
\r
57 **Important:** The file must be made executable:
\r
59 # chmod +x /usr/local/etc/rc.d/flexlm.sh
\r
61 You must also replace `***username***` above with the name of a valid user on your system (and not `root`).
\r
62 1. Start the license manager with the command:
\r
64 # /usr/local/etc/rc.d/flexlm.sh start
\r
67 ### 22.5.3 Linking the Java™ Runtime Environment
\r
69 Change the **Java™** Runtime Environment (JRE) link to one working under DragonFly:
\r
72 # cd $MATLAB/sys/java/jre/glnx86/
\r
73 # unlink jre; ln -s ./jre1.1.8 ./jre
\r
76 ### 22.5.4 Creating a MATLAB Startup Script
\r
78 1. Place the following startup script in `/usr/local/bin/matlab`:
\r
81 /compat/linux/bin/sh /compat/linux/usr/local/matlab/bin/matlab "$@"
\r
83 1. Then type the command `chmod +x /usr/local/bin/matlab`.
\r
85 **Tip:** Depending on your version of [`emulators/linux_base`](http://pkgsrc.se/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:
\r
88 if [ `expr "$lscmd" : '.*->.*'` -ne 0 ]; then
\r
91 (in version 13.0.1 it is on line 410) to this line:
\r
94 if test -L $newbase; then
\r
97 ### 22.5.5 Creating a MATLAB Shutdown Script
\r
99 The following is needed to solve a problem with MATLAB not exiting correctly.
\r
101 1. Create a file `$MATLAB/toolbox/local/finish.m`, and in it put the single line:
\r
103 ! $MATLAB/bin/finish.sh
\r
105 **Note:** The `$MATLAB` is literal.
\r
106 **Tip:** 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.
\r
107 1. Create a file `$MATLAB/bin/finish.sh`, which will contain the following:
\r
109 #!/usr/compat/linux/bin/sh
\r
110 (sleep 5; killall -1 matlab_helper) &
\r
113 1. Make the file executable:
\r
115 # chmod +x $MATLAB/bin/finish.sh
\r
118 ### 22.5.6 Using MATLAB
\r
120 At this point you are ready to type `matlab` and start using it.
\r
125 CategoryHandbook-linuxcompatibility
\r