GCC with MAC Terminal

This is a discussion on GCC with MAC Terminal within the Linux Programming forums, part of the Platform Specific Boards category; Hey guys: I'm taking a C programming class. I'm using the MAC OS X terminal and I'm trying to compile ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    116

    GCC with MAC Terminal

    Hey guys:

    I'm taking a C programming class. I'm using the MAC OS X terminal and I'm trying to compile just a simple program, but when I put in like:

    gcc hello.c

    this error comes out: -bash: gcc: command not found


    How do I go about fixing this?

    Also, what are some better program editors on the mac os x that I can use? I specifically like the color coding since it helps distinguish code quickly.

    Thanks

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129

  3. #3
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    TextWrangler is free and color codes. XCode is free - it comes on your install CDs. Install it.
    TextMate is nice, but is not free.

    TextEdit will work, but it's not great.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  4. #4
    Registered User
    Join Date
    Feb 2008
    Posts
    116
    so there is no way I can compile in the terminal shell?

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by dcwang3 View Post
    so there is no way I can compile in the terminal shell?
    Yes, you can.
    Code:
    gcc -o myprog myprog.c
    will compile "myprog.c" into an executable file called "myprog".

    For more info, check out "info gcc".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Registered User
    Join Date
    Feb 2008
    Posts
    116
    well, I'm asking that if I install the xcode program, will I be able to compile with gcc through the terminal shell rather than the xcode program?

    because right now, I can't compile using gcc I guess because xcode isn't installed on my mac

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by dcwang3 View Post
    well, I'm asking that if I install the xcode program, will I be able to compile with gcc through the terminal shell rather than the xcode program?

    because right now, I can't compile using gcc I guess because xcode isn't installed on my mac
    Yes, to the best of my knowledge you should be able to do that - I don't know if gcc is available as a separate package or is always a part of xcode - so what you need to do to install gcc, I can't really say. But gcc in itself is not a GUI application, so as long as your terminal process is able to run text applications, it should work fine with gcc. [you may of course also have to do some setup/configuration to get the path etc for gcc to be correct].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    Quote Originally Posted by dcwang3 View Post
    well, I'm asking that if I install the xcode program, will I be able to compile with gcc through the terminal shell rather than the xcode program?

    because right now, I can't compile using gcc I guess because xcode isn't installed on my mac
    If you install Xcode, yes, you will be able to use gcc from the terminal.

    All your pathing is dependent on your current directory and where you want your files to go based on where you are - business as usual as far as that goes.

    Todd
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  9. #9
    Registered User
    Join Date
    Feb 2008
    Posts
    116
    thanks guys, it works fine!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to Send Mac Address From Client to Server
    By Lieyza197 in forum C Programming
    Replies: 2
    Last Post: 05-27-2009, 09:58 AM
  2. Programming with C in Mac OSX Terminal
    By feroze in forum C Programming
    Replies: 2
    Last Post: 02-21-2009, 06:23 PM
  3. Console, Terminal and Terminal Emulator
    By lehe in forum C Programming
    Replies: 4
    Last Post: 02-15-2009, 08:59 PM
  4. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  5. Newbie Question - fflush(stdin) & fpurge(stdin) on Mac and PC
    By tvsinesperanto in forum C Programming
    Replies: 34
    Last Post: 03-11-2006, 11:13 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21