1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

help with compiling c++ code please!!

Discussion in 'Mac Programming' started by waterskier2007, Oct 25, 2007.

  1. macrumors 68000


    I need some help and i found an old thread but i couldnt really make heads nor tails of it. I am a college student, and today in lecture we used the terminal in Linux for the first time to compile a C++ code and run it. i asked the GSI, who i know is a mac user if the same commands would work in Mac Terminal and he said they should. I cant figure out how to compile the file. for this example the filename is


    we were given the code g++ sawTooth.cpp -o sawTooth

    in order to compile the file. i am trying to type this into terminal but i get a response that g++ is not a recognized command. if anyone could help with ways to compile a file that would be great
  2. Moderator


    Staff Member

    That's because you have to install the GNU C Compiler on your Mac before you can compile anything.

    Download the latest verison of XCode Tools (for free) from http://developer.apple.com
  3. macrumors 68000


    when i go to that site and look for xcode, the only thing i see is a xcode 2.4.1 which states that it is free for ADC members only, is it possible that i am viewing the wrong thing
  4. Moderator


    Staff Member

    Guess you missed the "Sign up for free ADC online membership" ad in the corner.

  5. macrumors 68040


    GCC comes with Xcode.

    There is a free level of ADC membership. You give them your email address and click through an EULA.
  6. macrumors 68000


    i found that thanks. thanks for the help
  7. macrumors regular


    i don't think xcode tools are necessary on linux. try gcc, g++, c++ etc.....depending on what compiler u are using.

Share This Page