MAC development Environment Configuration Related: Installing GCC

Source: Internet
Author: User
Tags gmp

From: Mac install GCC

The development toolchain in your Mac is all about Xcode, but it's not necessary to install a Xcode if you just want to use gcc,g++ to compile C + + code. Update: Version 4.3 of Xcode has released the graphical development interface and command-line tools separately. And even if Xcode is installed, the default GCC compiler is LVMM, not the pure GNU gcc. If you want to use pure gcc, the best way is to manually compile one yourself. There are two main methods:

1. Installation via homebrew

This method is relatively simple, if the MAC is already installed homebrew, the specific command:

Brew Tap Homebrew/versions

Brew install [flags] gcc49

where [flags] some need to support the language of eucalyptus, such as –enable-cxx–enable-fortran

2. Github

Reference Https://github.com/kennethreitz/osx-gcc-installer

3. Install by hand

This method can install the latest version of GCC, or any other required version

version=4.8.0

prefix=/usr/gcc-$ (VERSION)

Languages=c,c++,fortran

Make= ' make-j2′# compiled with two cores

Brew-path () {Brew Info $ | head-n3 | tail-n1 | cut-d "-F1;}

# Prerequisites

Brew Install GMP

Brew Install MPFR

Brew Install LIBMPC

# Download & Install the latest GCC

Mkdir-p $PREFIX

mkdir TEMP-GCC

CD TEMP-GCC

wget ftp://ftp.gnu.org/gnu/gcc/gcc-$VERSION/gcc-$VERSION. tar.gz

Tar xfz gcc-$VERSION. tar.gz

RM gcc-$VERSION. tar.gz

CD gcc-$VERSION

mkdir Build

CD Build

.. /configure \

–prefix= $PREFIX \

–with-gmp=$ (brew-path GMP) \

–with-mpfr=$ (Brew-path mpfr) \

–with-mpc=$ (Brew-path libmpc) \

–program-suffix=-$VERSION \

–enable-languages= $LANGUAGES \

–with-system-zlib \

–enable-stage1-checking \

–enable-plugin \

–enable-lto \

–disable-multilib

$MAKE Bootstrap

Make install

# Uncomment for cleanup ...

# CD: /.. /..

# Rm-r TEMP-GCC

When you are finished, you will install GCC in/usr/gcc-4.8.0, and then you can create a soft link to the GCC or add the bin path to the $PAHT variable

MAC development Environment Configuration Related: Installing GCC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.