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?
-
5Xcode is a free download for all members of the iOS and Mac Developer Programs. – Am1rr3zA May 08 '11 at 20:58
-
9It's only XCode 4 that you need to pay for - if you're not a paying developer. XCode 3.2.6 can be downloaded for free. – Rene Larsen May 08 '11 at 21:32
-
2XCode 4 is less than the price of a latté. – Ian C. May 08 '11 at 22:10
-
3@Ian C. - Stop shopping at Starbucks, then. – Fake Name May 09 '11 at 01:56
-
2@Ian C. in the mist of off-topicness, I'd like to point out (as someone who speaks a semi-decent italian) that the coffee you're referring to, is spelled caffè latte, and is also sometimes incorrectly spelled latté or lattè. ;) Regarding the price of Xcode, although I agree with the -should not affect you- cheap price of Xcode, the OP asked for a free way to get C++ compiler, which, cheap or not, is a valid question. I still think that Xcode and dev tools are a hell of a package for under 5 dollars. But to each his own. – Martin Marconcini May 09 '11 at 08:25
-
3@Martin: http://theoatmeal.com/blog/apps :) – Ian C. May 09 '11 at 13:09
-
Note that that Xcode has become free again see the Mac App Store - most of these answers are now out of date – mmmmmm Oct 22 '12 at 14:15
6 Answers
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.)

- 1,003
-
Note that only Xcode 4.1 (I think) on Lion had to be paid for all other versions are free wether from App Store or Developer downloads – mmmmmm Jan 22 '13 at 10:27
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.
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).

- 602
-
-
3
-
@ Martín Marconcini: Ohh, I see. I always wondered why they shipped my iMac with a unicorn, now it makes perfectly sense. – JustSid May 09 '11 at 09:38
-
Oops, I didn't realise that they don't also provide the binaries for it onthere. – Megan Walker May 09 '11 at 11:00
The Mac comes with software DVDs--one of those has Xcode. You can install it from there.

- 143
- 5
-
3This is pretty much the fastest way to get Xcode installed, albeit at the cost of getting a -possibly- outdated version. Since Apple curiously doesn't offer "upgrades", your (also free, as correctly pointed out in JustSid's answer) Xcode 3.x download will be a full 4GB++ package. – Martin Marconcini May 09 '11 at 08:27
-
For the unknown reason I can see only "Bundled Software" disk in the package and it didn't seem to contain xcode when I've tried to install.. So I've gone with the download solution. Anyways, thanks! – lyuba May 09 '11 at 21:00
-
This is the best way to bootstrap the latest GCC from open source if you can't or won't get a free Xcode 3 download by enrolling as a free Apple developer. – bmike Jul 01 '11 at 16:02
XCode does NOT come with the latest GCC and G++ (it comes with 4.2), so you still need to do your own install if you want the latest features. Macports and GNU do NOT provide sufficient instructions. So, it remains a mystery.
You can download XCode or find it on your install CD. That will give you you the older GCC/G++. Once you have that, you can download the latest GCC.
US, Tampa: http://mirrors-us.seosue.com/gcc/
BUT, how do you install??
All I know is..
- Unzip the folder. It should be named gcc-4.6.3 OR gcc-4.7.3 etc.
- Create a new folder ADJACENT to the gcc-4.6.3 folder, called buidgcc (the buildgcc folder and gcc-4.6.3 folder live in the same place. Possibly in the folder Developer/usr )
- Open a terminal (Applications->Utilities->Terminal)
Navigate to the buildgcc folder that you created Terminal Commmands cd .. brings you UP 1 level(note space between cd and .. ) ls tells you what files & folders are in the folder you're in cd/foldername lets you navigate into a folder
If you're in the buildgcc folder, type: ../gcc-4.6.3/configure WAIT. Then type: make WAIT a very long time.
Sorry. Here is where I'm stuck.

- 38,901
- 52
- 159
- 203

- 1
-
Macports does supply instructions on how to install - I have done it often – mmmmmm Oct 22 '12 at 14:16