可以先用
> brew info gcc49,
看看是否有安裝過, 如果沒有, 可以執行以下兩行
> brew tap homebrew/versions
> brew install -enable-cxx -enable-fortran gcc49
如果想自行手動安裝, 可以 :
1. 下載 gcc
2. 解開壓縮檔
> tar jxvf gcc-4.9-20131124.tar.bz2
3. 前期準備
> brew tap homebrew/versions
> brew install gmp
> brew install mpfr
> brew install libmpc
> brew install isl
> brew install clo
> brew install cloog
4. shell script
#!/bin/bash
VERSION=4.9.0
PREFIX=/usr/local/Cellar/gcc49
LANGUAGES=c,c++,fortran,java,objc,obj-c++
MAKE="make -j2"
brew-path() { brew info $1 | head -n3 | tail -n1 | cut -d ' ' -f 1; }
mkdir build
cd build
../configure \
-build=x86_64-apple-darwin13.0.0 \
-prefix=$PREFIX \
-with-gmp=$(brew-path gmp) \
-with-mpfr=$(brew-path mpfr) \
-with-mpc=$(brew-path libmpc) \
-enable-languages=$LANGUAGES \
-enable-shared \
-enable-threads=posix \
-with-system-zlib \
-enable-stage1-checking \
-enable-plugin \
-enable-lto \
-disable-multilib
5. compile
> make bootstrap
> make install
6. Install
在 /usr/bin/ 建立新link
> sudo ln -s /usr/local/bin/gcc-4.9 /usr/bin/gcc
> sudo ln -s /usr/local/bin/g++-4.9 /usr/bin/g++
ref: http://www.leexiang.com/install-gcc-on-mac
====
compile error
(1)
ctype_members.cc:132:3: error: redefinition of ‘bool std::ctype<wchar_t>::do_is(std::ctype_base::mask, std::ctype<wchar_t>::char_type) const’
ctype<wchar_t>::
^
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37059
方法: 拿掉 configure 參數: -enable-clocale=gnu , 刪掉 build 重做
留言列表