SPM/Installation on 64bit Linux
< SPMAll 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.
SPM12
Installation
Download spm12.zip and its updates spm12_updates_rxxxx.zip in your home directory then type the following in a Terminal:
cd /home/login
unzip spm12.zip
unzip -o spm12_updates_rxxxx.zip -d spm12
Start MATLAB and add SPM into your path, either using File > Set Path > Add Folder... or typing
addpath /home/login/spm12
in MATLAB's workspace.
Compilation
In a Terminal, from the src folder of your SPM12 installation, type:
cd /home/login/spm12/src
make distclean
make && make install
make external-distclean
make external && make external-install
SPM8
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.
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
Required development packages: make, gcc.
SPM5
Installation
Download spm5.zip and its updated MEX files SPM5_Matlab7.9_LINUX64_MEX.zip in your home directory then type the following in a Terminal:
cd /home/login
unzip spm5.zip
unzip -o SPM5_Matlab7.9_LINUX64_MEX.zip -d 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.
Compilation
In a Terminal, from the src folder of your SPM5 installation, type:
cd /home/login/spm5/src
make distclean
make && make install
SPM2
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.
Compilation
In a Terminal, type:
cd /home/login/spm2
make clean.Linux.A64
make Linux.A64
Troubleshooting
"bad image handle dimensions" error
The error "bad image handle dimensions" when trying to display an image is an indication that you need to (re)compile the SPM MEX files.
"cannot find -lstdc++" error
If you get the error message "cannot find -lstdc++", you can install the libstdc++5 package using your package manager (e.g. using sudo apt-get install libstdc++5 on Ubuntu), or see the "Other problems with lstdc++" section below.
If, after the install of libstdc++5, the lstdc++ error persists, just do a symbolic link like
ln -s /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so
and it should work. If not, see next.
Alternatively, you might be tempted to follow these instructions: http://www.lukedodd.com/?p=225
Other problems with lstdc++
If you get the above error and cannot install libstdc++ (e.g. you do not have root/admin access), or if you get other problems such as "... version `GCC_4.2.0' not found (required by /usr/lib64/libstdc++.so.6", then another option is to edit your mexopts.sh config file and delete or disable the -lstdc++ compiler flags, for example simply use find-and-replace to delete all instances of -lstdc++. SPM will compile properly without this.
It's best to edit a local copy of mexopts.sh (the original is found in the bin directory with your matlab and mex executables). If you run mex -setup
it will interactively create a copy for you, under ~/.matlab/RELEASE
for example
~/.matlab/R14SP3/mexopts.sh ~/.matlab/R2008b/mexopts.sh
or similar, and you may then further edit that copy if required. If you match the release, mex will find your copy of mexopts.sh. Note that from MATLAB
version
should show you the release, but with parentheses around it, e.g. "(R14SP3)".
"mex: command not found" error
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:
Another solution is to edit the Makefile (spm8/src/Makefile.var
for SPM8 or spm5/src/Makefile
for SPM5) and mention the full path when referring to MEXBIN:
MEXBIN = /usr/local/matlab/mex
"This is pdfTeX, Version ... (TeX Live 2011)" error
If you get the error:
mex: unrecognized option `-O' mex: unrecognized option `-c' This is pdfTeX, Version ... (TeX Live 2011)
This is due to a conflict between MATLAB mex and a LaTeX command (from the texlive package) with the same name. Change PATH or MEXBIN as described in the previous solution.
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".
Compilation notes for SPM2:
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.
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.