8 Replies Latest reply: Jan 15, 2011 6:58 PM by etresoft
lablady Level 1 Level 1 (25 points)
My son is taking a C++ class and is trying to figure out how to save (& run) a file as a .cpp in a Mac? (Terminal does not understand g++ command.)

He'll ask his professor on Monday but I thought I'd try to help him out now. I didn't find anything through the 'search forum' option.

He has a MacBook w/Snow Leopard. Thanks!

lablady

eMac, iMac, MacBook, Mac OS X (10.6.6)
  • etresoft Level 7 Level 7 (25,620 points)
    The first step is to install Xcode. That will give you all of the g++ commands in the Terminal. You already have vim, etc. so once Xcode is installed the Mac's Terminal will operate the same as any Linux machine. If he is just now learning C++, I would advise sticking with the Terminal for now. As some point he may want to build true MacOS X applications with Xcode, but that wouldn't help with a class.
  • thomas_r. Level 7 Level 7 (29,580 points)
    He will need the gcc compiler that is part of the Mac OS X Developer Tools. You can download it here:

    http://developer.apple.com/technologies/xcode.html

    Note that you will need to join the Apple Developer program, which you can do for free here:

    http://developer.apple.com/programs/register/

    Note that, to get the best answers, further questions along these lines should be directed to one of the developer forums here:

    http://discussions.apple.com/category.jspa?categoryID=162
  • etresoft Level 7 Level 7 (25,620 points)
    Thomas A Reed wrote:
    He will need the gcc compiler that is part of the Mac OS X Developer Tools. You can download it here:

    http://developer.apple.com/technologies/xcode.html

    Note that you will need to join the Apple Developer program, which you can do for free here:

    http://developer.apple.com/programs/register/


    You only need to join the Apple Developer program if you want to download Xcode. It would be better to use the Xcode installer that is in the "Optional Install" folder on your MacOS X installer DVD. Otherwise, it is something like a 1.6 GB download that will take a while.
  • thomas_r. Level 7 Level 7 (29,580 points)
    Ahh, is it still on the install disks? I remember when it came on a separate disk, but I haven't paid attention to that lately, and with all the changes Apple has made to the developer program lately, I thought it might be download-only now. Thanks for the clarification!

    See, excellent example of why the developer forums are the best places to ask these sorts of things!
  • etresoft Level 7 Level 7 (25,620 points)
    Thomas A Reed wrote:
    Ahh, is it still on the install disks? I remember when it came on a separate disk,


    Yes. That was back when the OS came on CD-ROM. The version on the DVD doesn't have tools for iOS development, but it is fine for MacOS X development and especially a C++ class. People complain, and rightly so, that each incremental update of Xcode is another multi-gigabyte download.
  • thomas_r. Level 7 Level 7 (29,580 points)
    Yeah, I'd complain about that too, if I were still doing that kind of development. But I'm doing all web-based stuff these days.
  • lablady Level 1 Level 1 (25 points)
    Thank you all. Unfortunately, he left the installation DVD's home. Guess I'll have to mail them to him.

    Can any of you tell him how he can save a file as a .cpp, though? Thanks!!

    lablady
  • etresoft Level 7 Level 7 (25,620 points)
    lablady wrote:
    Thank you all. Unfortunately, he left the installation DVD's home. Guess I'll have to mail them to him.


    If he is at a university he should be able to sign up for a free developer account and download Xcode fairly quickly.

    Can any of you tell him how he can save a file as a .cpp, though? Thanks!!


    That depends on what he is using. To write source code, one must use a plain text editor. Xcode includes such an editor. There are a number of editors built in to the Terminal, such as vi and nano. Basic understanding of how to use vi would be very, very useful. If he wants something fancier, there is always TextWrangler and at least two dozen like it.