[Mac] Homebrew で apple-gcc42 をインストールする方法
Xcode 4.2.1 から gcc が llvmgcc とかいうのに変わってしまい、今までの gcc を使うためには別途インストールしないといけません。
■ llvmgcc
$ gcc -v Using built-in specs. Target: i686-apple-darwin11 Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.1~22/src/configure --disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.1~22/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1 Thread model: posix gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00) |
そこで、Homebrew で apple-gcc42 をインストールする方法を調べたので、ご紹介します。
まず、デフォルトの Formula には AppleGCC や GNU GCC はないので、github にある非公式Formulaから直接、インストールします。
$ brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb ==> Downloading http://r.research.att.com/tools/gcc-42-5666.3-darwin11.pkg ######################################################################## 100.0% ==> Caveats NOTE: This formula provides components that were removed from XCode in the 4.2 release. There is no reason to install this formula if you are using a version of XCode prior to 4.2. This formula contains compilers built from Apple's GCC sources, build 5666.3, available from: http://opensource.apple.com/tarballs/gcc All compilers have a `-4.2` suffix. A GFortran compiler is also included and is the exact same version as the compiler provided by the `gfortran` formula in the main repository. ==> Summary /usr/local/Cellar/apple-gcc42/4.2.1-5666.3: 106 files, 75M, built in 115 seconds |
gcc-4.2 コマンドで apple-gcc42 が使えるようになりました。
$ gcc-4.2 -v Using built-in specs. Target: i686-apple-darwin11 Configured with: /Volumes/Media/Builds/gcc-5666.3/build/obj/src/configure --disable-checking --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++,fortran --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/include/c++/4.2.1 Thread model: posix gcc version 4.2.1 (Apple Inc. build 5666) (dot 3) |
以上です。
参考情報
・Build gcc 4.6.2 on Mac OS X Lion | Re: no subject