Nugroho's blog.: Installing GCC 4.6.2 on OSX Lion

Wednesday, December 14, 2011

Installing GCC 4.6.2 on OSX Lion

After searching how to's, compiling from source, installing Snow Leopard version of Xcode (on its DVD) and installing light alternate gcc 4.2 version without success (or success but not satisfied), I  installed Xcode 4.2 on my OS X Lion. Alas, Apple ship its own GCC compiler, llvm-gcc, instead GCC. So I download tar.gz version of GCC-4.6.2 from GNU and try to install it
From Blogsy Photos
From Blogsy Photos
check to know what dependencies I don't have by typing

./configure



the result is
 

configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.


So, I download it mpc (http://www.multiprecision.org/index.php?prog=mpc&page=download), mpfr(http://www.mpfr.org/mpfr-current/#download) and gmp(http://gmplib.org/). I don't know why gmp's download always ended by error, duh. Trying to 'torrenting' it via burnbit but still get error. I was forced to use ftp connection via Finder (Command-K) and done. Installing these dependencies is easy task, just unzip/untar these archive, cd to its directory and type three magical UNIX installation words.

$./configure
$make
$sudo make install

OK, now it's GCC time. Extract GCC zipped file, cd to its directory

./configure
make
sudo make install

You can add make command to make -j 4 if you have multicore processor and want to make process processed in parallel. "Make" process is very long time process.
Look at gnumake, cc1 , sh , and llvm-gcc-4.2 processes. They're processed in parallel.
From Blogsy Photos
From Blogsy Photos
From Blogsy Photos

 OMG, after long awaiting time, I got an error, something about libgfortran. (update: it's succeed indeed despite of error, it actually compiled gcc but not in Lion path, so Lion's still use llvm-gcc version , I post the update here) After a minute of thinking, I decide to compile just C for now, and build on separate directory and output-ed it on my home directory

Nugrohos-MacBook-Pro:gcc-4.6.2 nugroho$ mkdir build
Nugrohos-MacBook-Pro:gcc-4.6.2 nugroho$ cd build
Nugrohos-MacBook-Pro:build nugroho$ ../configure --prefix=$HOME/gcc462 --enable-languages=c

These command will build GCC on 'build' directory and store the compilation result on gcc462 directory on my home folder. If you are interested in building only a limited set of languages, just like me, you could also specify this option in the configure line. For example if you need only C, C++ and Fortran just append this to the above line: --enable-languages=c,c++,fortran

No comments:

323f (5) amp (1) android (12) apple (7) arduino (18) art (1) assembler (21) astina (4) ATTiny (23) blackberry (4) camera (3) canon (2) cerita (2) computer (106) crazyness (11) debian (1) delphi (39) diary (286) flash (8) fortran (6) freebsd (6) google apps script (8) guitar (2) HTML5 (10) IFTTT (7) Instagram (7) internet (12) iOS (5) iPad (6) iPhone (5) java (1) javascript (1) keynote (2) LaTeX (6) lazarus (1) linux (29) lion (15) mac (28) macbook air (8) macbook pro (3) macOS (1) Math (3) mathematica (1) maverick (6) mazda (4) microcontroler (35) mountain lion (2) music (37) netbook (1) nugnux (6) os x (36) php (1) Physicist (29) Picture (3) programming (189) Python (109) S2 (13) software (7) Soliloquy (125) Ubuntu (5) unix (4) Video (8) wayang (3) yosemite (3)