how do i build gcc on a mac?

前端 未结 4 2279
一生所求
一生所求 2021-02-19 13:09

I\'d like to build the latest version of gcc on a mac. I have the latest xcode but I\'m looking for some of the c++0x features that are in more recent versions (the lambda funct

相关标签:
4条回答
  • 2021-02-19 13:51

    One option is to install MacPorts and install the gcc46 package:

    sudo port install gcc46
    

    Another option is to download the source code and build it as follows:

    tar xzvf gcc-4.6.0.tar.gz
    cd gcc-4.6.0
    ./configure
    make
    

    Note that GCC 4.6.0 requires as prerequisites GMP 4.2+, MPFR 2.3.1+, and MPC 0.8.0+. If ./configure fails, it's probably because you're missing one of these (though it should give you a helpful error message in any case).

    Building will take a while—likely several hours, depending on your hardware.

    0 讨论(0)
  • 2021-02-19 13:59

    You should look at the Homebrew project.

    Homebrew allows you to do things like this:

    brew install gcc
    

    Mac homebrew installation instructions are available here.

    0 讨论(0)
  • 2021-02-19 14:01

    I would suggest building it yourself (Adam details how to do so). This will give you fine control on where to install and all the options you want to select. My experience from having multiple versions of gcc is that, if care is not taken apple's version of gcc can be damaged.

    To speed up gcc installation you might want to look at --enable-languages option. If there are languages you don't need installed with the new gcc then you may not want to select them.

    0 讨论(0)
  • 2021-02-19 14:05

    Add GCC support to a fresh Xcode 4.2 installation using this homebrew formula:

    brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb
    

    Upgrading from Xcode 4.1 doesn't drop existing GCC support, so this formula is only useful if you're working with a fresh 4.2+ installation.

    0 讨论(0)
提交回复
热议问题