Minhbach's Weblog

June 5, 2013

Install multiple version of gcc

Filed under: IT — minhbach @ 6:44 am

Down load gcc source
Remove config.cache
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

 

Matlab: http://www.lukedodd.com/compiling-gcc-4-3-4-under-ubuntu-11-10-for-matlab/

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:
–enable-clocale=gnu –enable-shared
–enable-threads=posix –enable-__cxa_atexit
–enable-languages=c,c++ –disable-libstdcxx-pch

http://www.lukedodd.com/compiling-gcc-4-3-4-under-ubuntu-11-10-for-matlab/

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: