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

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?

Best Answer

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.)