作者:lch
 
matlab  for      Linux  安装 
(  安装方法文档是从网上查资料+ 实践得到的 )
一. 
1. 
[wzh@localhost ~]$ su
[root@localhost ~]$ mkdir /usr/matlab
 
2. 
[root@localhost wzh]# mount -o loop -t iso9660 /mnt/hda7/soft/MatlabR14Linux/Matlab_R14_Mac.Linux.Unix_CD1.iso /media/cdrom
 
3.  拷贝license.dat( 不同的光盘可能位置不一样)
[root@localhost wzh]# cd /usr/matlab
[root@localhost matlab]# cp /media/cdrom/Matlab.7.R14.License-Mac.OS.X-Unix-Linux/Matlab.7.R14.License-Mac.OS.X-Unix-Linux/license.dat .
( 这个点不可少,拷贝到当前目录)
 
4. 
[root@localhost matlab]# /media/cdrom/install
在Fedora8  下会提示出错(Everest 0.5 下正常) : /tmp/3012tmwinstall/update/bin/glnx86/xsetup: error while loading shared libraries: libXp.so.6: cannot open shared object file: No such file or director
 
我的报错是这样的: 
/tmp/2712tmwinstall/update/install/abort.sh: line 15: /tmp/2712tmwinstall/update/install/cleanup.sh: 
解决办法跟下面是一样的
 
解决办法:将CD1 中的update/bin/glnx86/libmwins.so  拷贝到 /usr/lib  目录,然后更名为 libXp.so.6
[root@localhost matlab]# cp /mnt/cdrom/update/bin/glnx86/libmwins.so /usr/lib/libXp.so.6
然后再开始install
 
5.  中间需要换光盘,另开一个shell 按提示载和CD2 和CD3
[root@localhost wzh]# umount /media/cdrom
[root@localhost wzh]# mount -o loop -t iso9660 /mnt/hda7/soft/MatlabR14Linux/Matlab_R14_Mac.Linux.Unix_CD2.iso /media/cdrom
[root@localhost wzh]# umount /media/cdrom
[root@localhost wzh]# mount -o loop -t iso9660 /mnt/hda7/soft/MatlabR14Linux/Matlab_R14_Mac.Linux.Unix_CD3.iso /media/cdrom
 
6.  重新载入CD1 ,拷贝并修改license.lic
[root@localhost wzh]# umount /media/cdrom
[root@localhost wzh]# mount -o loop -t iso9660 /mnt/hda7/soft/MatlabR14Linux/Matlab_R14_Mac.Linux.Unix_CD1.iso /media/cdrom
[root@localhost wzh]# cp /media/cdrom/Matlab.7.R14.License-Mac.OS.X-Unix-Linux/Matlab.7.R14.License-Mac.OS.X-Unix-Linux/license.lic /usr/matlab/etc/
[root@localhost wzh]# kwrite /usr/matlab/etc/license.lic ( 或gedit /usr/matlab/etc/license.lic )
使用命令得到hostname
[root@localhost matlab]# hostname
localhost.localdomain
将得到的hostname 写入license.lic
SERVER localhost.localdomain ANY 5353
保存文件,如果提示只读无法保存(Fedora8 中出现这种情况)
 
则 
[root@localhost wzh]# chmod 755 /usr/matlab/etc/license.lic 
(如果用vi 编辑的话可以用wq!
 
到此安装结束,用命令/usr/matlab/bin/matlab 即可运行matlab
 
 
二. 
1. 
在桌面或任务栏,建立一个启动器(快捷方式),在命令一栏中输入/usr/matlab/bin/matlab -desktop 就可以了。注意-desktop
 
2.  中文支持(我用的是方法一,其它的没试过
方法一: 
打开matlab/sys/java/jre/glnx86/jre1.4.2/lib/ 下的font.properties
filename.--misc-simsun-medium-r-normal-*-*-120-*-*-c-*-gbk-0=/usr/share/fonts/zh_CN/TrueType/simsun.ttc
appendedfontpath=/usr/share/fonts/zh_CN/TrueType/
其中的simsun.ttc 是从windows 拷贝过去的,当然也可以不用它,只要是支持中文的字体即可。比如Fedora8 该目录下的zysong.ttf
其中"filename." 属性用于指定matlab
"appendedfontpath"
然后在matlab
方法二: 
也可以把字体直接拷贝到或链接到matlab/sys/java/jre/glnx86/jre1.4.2/lib/fonts 下,再启动matlab
方法三(建议使用): 
由于Matlab 自带的jre 比较老,建议升级到最新的jre ,到www.java.com 下载最新的jre1.6u3 ,由于我上不了该网站,所以使用迅雷搜索下载了1.6u1 ,下载bin 文件后,建立一个目录,
mkdir /usr/wzh/tmp
cd /usr/wzh/tmp
sudo sh /usr/wzh/Downloads/XXX.bin
这样就会将jre 安装到/usr/wzh/tmp
然后将该目录下的jre1.6.0_01 文件夹拷贝或移动或链接到/usr/matlab/sys/java/jre/glnx86
,然后修改/usr/share/matlab/sys/java/jre/glnx86/jre.cfg 文件,将其中的1.4.2 修改成1.6.0_01 ,这样,matlab 就会使用1.6.0_01 的jre 来启动了,新的jre
这样,不需要修改任何的文件,启动matlab 后,在preferences 的fonts
 
3.  据说中文环境容易死机,因为我的系统为英文环境,所以以下为摘抄( 我的是中文环境,所以会出问题啦)
第一步,安装完matlab r2007a 后,在中文环境中启动时,matlab 容易死机,而在英文环境中却能正常工作!这就说明是matlab
第二步,环境变量的设置: 
 
 
修改matlab 安装目录下bin 目录下的matlab
/1.  进入matlab 安装目录下的bin
/2. sudo vi matlab
/3.  在#! /bin/sh 的下一行加上 LANG=en_AU.UTF-8 LANG=en_AU.UTF-8 XMODIFIERS=
/
被实践成功的方法: 
1. 运行matlab 目录下的install_matlab ,按提示完成(基本都是按Enter
2. 直接在终端输入matlab
 
5.  如果不能使用simulink ,参照如下方法(网上搜索到的)
This december, I was migrating some of the nodes to Fedora Core 6. Those machines were primarily windows 2000 nodes and serve students in electronics during their practical classes. 
     An error status was returned by the program ’xsetup’, the X Window System version of install. The following messages were written to standard error: 
 
question 1
/tmp/2493tmwinstall/update/bin/glnx86/xsetup: error while loading shared libraries: libXp.so.6: cannot open shared object file: No such fileor directory 
solution: yum install libXp-devel 
 
(我的只出现了这个问题,如果你出了其它问题,那我也没办法了,你只能自己去试了。如果你没出问题,那就恭喜你了。^_^
question 2 :Fixing simulink:Warning: Could not access OpenGL library 
solution: 
( 到/usr/matlab/ 目录下运行)
#yum install libXpm-devel mesa-libGL-devel 
 
(这一段不用管它) 
mesa-libGLU-devel
GCC 3.4 dependencies for simulink 
[root@localhost matlab]ldd/usr/local/matlab/bin/glnx86/glren.so 
/usr/local/matlab/bin/glnx86/glren.so 
/usr/local/matlab/bin/glnx86/../../sys/os/glnx86/libgcc_s.so.1: version `GCC_4.2.0’ not found (required by /usr/lib/libstdc++.so.6) 
/usr/local/matlab/bin/glnx86/glren.so: /usr/local/matlab/bin/glnx86/../../sys/os/glnx86/libgcc_s.so.1: version `GCC_3.3’ not found (required by /usr/lib/libstdc++.so.6)........ 
 
Solution: 
#yum install compat-gcc* 
#cd /usr/local/matlab/sys/os/glnx86 
#mv libgcc_s.so.1 libgcc_s.so.1_back 
#ln -s /lib/libgcc_s.so.1 libgcc_s.so.1 
 
Question 3 :broken symbolic link with simulink Part One: Can’t load’/usr/local/matlab/bin/glnx86/libmwsimulink.so’: libXft.so.1: cannot open shared object file: No such file or directory 
Solution: 
[root@localhost matlab]# updatedb && locate libXft.so 
/usr/lib/libXft.so 
/usr/lib/libXft.so.2 
/usr/lib/libXft.so.2.1.2 
[root@localhost matlab]# ln -s /usr/lib/libXft.so.2 /usr/lib/libXft.so.1 
 
Question 4: broken symbolic link with simulink Part Two: Can’t load ’/usr/local/matlab/bin/glnx86/libmwsimulink.so’:/usr/local/matlab/bin/glnx86/libqt-mt.so.3: undefined symbol: XftFreeTypeOpen 
Solution: 
yum install qt 
mv/usr/local/matlab/bin/glnx86/libqt-mt.so.3 usr/local/matlab/bin/glnx86/libqt-mt.so.3_back 
ln -s /usr/lib/qt-3.3/lib/libqt-mt.so.3 /usr/local/matlab/bin/glnx86/libqt-mt.so.3 
至此,你就应该可以使用simulink
 
6. Support for maple interface( 摘抄,没试过)
[ 最新的matlab7.3 版本似乎已经解决了符号运算功能]
export LD_ASSUME_KERNEL=2.4.1
(...)
6 、Support for compiling a mex file( 摘抄,没试过)
[ 最新版本的matlab7.3 即2006b 已经可以使用gcc4.1.0 编译mex 文件,虽然官方支持的版本为3.4.0-3.4.5]
[ 在编译mex 文件前,执行mex -setup 设置编译环境]
I'm trying to compile a Mex file on SuSE linux 10.1, which uses GCC 4.1.0.
The file compiles fine, but when I try to run it I get this error:
/opt/Matlab/bin/glnx86/../../sys/os/glnx86/libgcc_s.so.1: version
`GCC_3.3' not found (required by /usr/lib/libstdc++.so.6).
From the documentation, it appears as though Matlab only supports GCC 3.2.3. I suspect that my only solution is to download and compile this compiler and then use it to compile my mex file.If you must use gcc 3.2.3, your best bet is to first build and install gcc 3.3.6, and then use that to build gcc 3.2.3.
3.1. build and install gcc 3.3.6 first
download gcc-3.3.6.tar.bz2 to /home/max/
cd home/max
tar xjvf gcc-3.3.6.tar.bz2 # $srcdir=/home/max/gcc-3.3.6
mkdir objdir
cd objdir
$srcdir/configure --prefix=/opt/gcc-3.3.6 # or wherever
make bootstrap
<wait a long time>
su
make install
3.2 and then use gcc 3.3.6 to build gcc 3.2.3
export PATH=/opt/gcc-3.3.6/bin:$PATH
export LD_LIBRARY_PATH=/opt/gcc-3.3.6/lib:$LD_LIBRARY_PATH
mkdir objdir
cd objdir
$srcdir/configure --prefix=/opt/gcc-3.2.3 # or wherever
make bootstrap
<wait a long time>
su
make install
3.3 now, compile your mex file, before compiling do
export PATH=/opt/gcc-3.2.3/bin:$PATH
 
 
三. OK ! Matlab 
 t = linspace( -2, 2, 400 );
 f=sign(t).*rectpuls(t,2);
 figure(4), plot(t,f);
 xlabel('Time(sec)'),ylabel('f(t)');