SPM/Installation on 64bit Linux
From Wikibooks, the open-content textbooks collection
All versions of SPM are supported under Linux 64 bit and the installation should be fairly the same with any version. You might have to recompile SPM MEX files (*.mexa64) if those provided with the SPM distribution do not appear to be compatible with your system.
Contents |
[edit] SPM8
[edit] Installation
Download spm8.zip and its updates spm8_updates_rxxxx.zip in your home directory then type the following in a Terminal:
cd /home/login unzip spm8.zip unzip -o spm8_updates_rxxxx.zip -d spm8
Start MATLAB and add SPM into your path, either using File > Set Path > Add Folder... or typing
addpath /home/login/spm8
in MATLAB's workspace.
[edit] Compilation
In a Terminal, from the src folder of your SPM8 installation, type:
cd /home/login/spm8/src make distclean make && make install make toolbox-distclean make toolbox && make toolbox-install make external-distclean make external && make external-install
[edit] SPM5
[edit] Installation
Download spm5.tar.gz, its updates Updates_xxxx.tar.gz in your home directory then type the following in a Terminal:
cd /home/login tar xvfz spm5.tar.gz tar xvfz Updates_xxxx.tar.gz -C spm5
Start MATLAB and add SPM into your path, either using File > Set Path > Add Folder... or typing
addpath /home/login/spm5
in MATLAB's workspace.
[edit] Compilation
In a Terminal, from the src folder of your SPM5 installation, type:
cd /home/login/spm5/src make distclean make && make install
[edit] SPM2
[edit] Installation
Download spm2.tar.gz and its updated MEX files SPM2_LINUX64_MEX.tar.gz in your home directory then type the following in a Terminal:
cd /home/login tar xvfz spm2.tar.gz tar xvfz SPM2_LINUX64_MEX.tar.gz -C spm2
Start MATLAB and add SPM into your path, either using File > Set Path > Add Folder... or typing
addpath /Users/login/spm2
in MATLAB's workspace.
[edit] Compilation
In a Terminal, type:
cd /home/login/spm2 make clean.Linux.A64 make Linux.A64
[edit] General comments
The error "bad image handle dimensions" when trying to load files is an indication that you need to (re)compile the SPM MEX files.
[edit] Prerequisites
[edit] Hardware
A cpu that supports the x86-64 architecture.
[edit] Software
- Operating system
A 64bit Linux distribution for the x86-64 architecture.
- Compiler & Libraries
GCC version 3.4.0 or later. This is the first GCC release with proper x86-64 support. Glibc version 2.3.0 or later
- Matlab
Matlab R14 SP1 or newer, as this is the first Matlab release that supports the x86-64 architecture.
[edit] Compilation Troubleshooting
[edit] lstdc++ not Required
If you get the error message "cannot find -lstdc++", you can edit your mexopts.sh config file and delete or disable the -lstdc++ compiler flags. It will compile properly without these flags.
Another solution is to install the libstdc++5 package using your package manager.
With the install of libtdc++5, the lstdc++ error persist, just do a symbolic link like
ln -s /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so
and it should work fine
[edit] MEX Required
If you get the error "mex: command not found" check that mex is in your path. Either add the matlab binary directory (usually /usr/local/matlab/bin) to your path or create a link to mex somewhere already in the path (usually /usr/local/bin).
- Adding the path:
- Type:
PATH=/usr/local/matlab/bin:$PATH
- Type:
- Creating a Link:
- Enter your local binary direcotry:
cd /usr/local/bin - Create the link:
ln -s /usr/local/matlab/bin/mex - (Note: Creating a link in /usr/local/bin requires root privileges).
- Enter your local binary direcotry:
[edit] Missing files
If you get build errors such as math.h does not exist when trying to execute the command "make && make install", then you probably need to install the build-essentials package. At the command line type: "sudo aptitude install build-essential" (for Ubuntu). if you have sudo privileges or simply log in as root or obtain superuser status and type: "aptitude install build-essential". After the package is downloaded and installed retry "make && make install" in the spm5/src directory and you should be good to go.
[edit] Compilation notes for SPM2:
[edit] Updates for Makefile
In order to make the recompilation process work, the Makefile provided in the spm2.tar.gz package needs to be patched. Also the file spm_platform.m needs an update.
The updated Makefile adds a new architecture, Linux.a64:
Linux.a64:
make all SUF=mexa64 CC="gcc -O3 -funroll-loops -fPIC -march=x86-64" \
MEX="mex COPTIMFLAGS='-O3 -funroll-loops -fPIC -march=x86-64'"
Plus an appropriate section for clean and verb.mexa64.
The -fPIC option is necessary to allow linking on 64bit Linux.
-march=x86-64 provides generic optimisations for both Opteron and 64bit Xeon. If the code is running on a 64bit Xeon you can change it to -march=nocona (the first revision of the Xeon processor supporting EM64T had codename nocona), if you have an Opteron or Athlon64, change it to -march=opteron. This might give you an extra performance boost.
[edit] Updates for spm_platform.m
Matlab for 64bit Linux identifies itself as GLNXA64 as opposed to GLNX86 when running 32bit Matlab. Endian-ness doesn't change, so I added this to the PDefs cell list:
'GLNXA64', 'unx', 0;...
and added GLNXA64 to the list of other unix platforms at the font configuration.