cgccmacos-high-sierrabochs

How can I install gcc 4.2.1 on OSX Sierra?


I'm using the Bochs emulator and for my class we're using gcc 4.2.1. I believe I've gotten Bochs running, but now I need to compile our programs which are compatible with gcc 4.2/.1.

I understand OSX uses an alias for gcc 4.2.1, but how can I use gcc specifically and not clang?

Edit: GCC 4.6.3 not 4.2.1 sorry


Solution

  • You can install previous version of gcc pretty easily using homebrew.

    If you have homebrew installed you can get gcc 4.9 by running

    brew install gcc@4.9
    

    After it is installed gcc will still map to the clang that came with your mac. The newly installed gcc will be installed at /usr/local/bin and be called something like gcc-4.

    You can find the exact executable name using

    ls /usr/local/bin | grep gcc

    Hopefully 4.9 is close enough to 4.6 for your purposes.