How to install g++ or c++ without paying for xcode?

I need to install node.js on my new Mac and it requires having c++ or g++ compiler installed. How do I get one without paying for xcode?


Solution 1:

You can still download Xcode 3.x for free with a free developer account. Xcode 3 comes with the GCC 4.2, LLVM-GCC 1.5 and LLVM 1.5 so everything you need to compile C++, C and ObjC code.

(Remark: LLVM 1.5 can't compile C++ code, so you have to switch back to LLVM-GCC or GCC for this.)

Solution 2:

Just to be complete - Xcode 4.1.1 is free on the App Store but it requires Lion which implies a recent hardware purchase or paying for the upgrade.

Solution 3:

OSX GCC Installer

Downloading and installing the massive Xcode installer is a huge hassle if you just want GCC and related tools.

The osx-gcc-installer allows you to install the essential compilers from either pre-built binary packages or helps you create your own installer.

First mentioned here by Dancek

Solution 4:

You could get gcc for MacOSX from Apples Open Source site: http://opensource.apple.com/release/developer-tools-40/ It doesn't come with any instructions though.

(I think gcc is suitable, please feel free to correct me if I'm wrong).

Solution 5:

The Mac comes with software DVDs--one of those has Xcode. You can install it from there.