Down load gcc source
export CC=”gcc-4.5″ ./configure
export CC=”gcc-4.5″ make
make bootstrap instead of make
Run config with
Configure export CC=/path/to/desired/compiler
Now you just need to point Matlab to this version of gcc.
Run “mex -setup” from matlab to ensure you have a mexopts.sh file – it should tell you where it is. Edit the mexopts.sh (mine was in $HOME/.matlab/R2011b/mexopts.sh):
- Replace all instances of CC=”gcc” with CC=”/opt/gcc-4.3.4/bin/gcc”.
- Replace all instances of CXX=”g++” with CC=”/opt/gcc-4.3.4/bin/g++” (and the same for gfortran if you use it).
- Add a line with “export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu” at the top (this stops more “/usr/bin/ld: cannot find crti.o” errors from happening when you use mex).
Now you should be able to compile and run Matlab mex files.
./configure –prefix=/usr/local/ –enable-languages=c,c++
LFS uses quite a few more options and they are explaining exactly why they are being used and not using them can lead to all sorts of problems later on or even during build…
Their recommended options are these: