Best C Complier for OSX?

Discussion in 'Mac Programming' started by macbookpro10, Aug 24, 2006.

  1. macrumors newbie

    Joined:
    Jun 7, 2006
    #1
    Hey guys. Maybe you can help me out. I signed up for a C Programming course for college. The teacher has no idea about macs and said to use the terminal. I need a stable free C/C++ Compiler. The one he recommends for XP is http://www.bloodshed.net/devcpp.html (DEV C++) but it doesn't come for OSX. Can someone help me out so I can have a visual Run/Compile/Save application compatible for C and C++. Thanks again.
    Joe
     
  2. macrumors 6502

    Joined:
    Jul 25, 2006
    #2
    Well, pretty much the only free compiler for OSX is gcc. Thank goodness it's a pretty darn good compiler and you already have it if you installed the developer tools on your Mac. You can then use Xcode as a front end for it if you're not used to using the command line.
     
  3. thread starter macrumors newbie

    Joined:
    Jun 7, 2006
    #3
    Can you tell me how I can get to this and access it? I do not see it. Thanks. Is there really no open source compiler comparable to XP ones? That is surprising.
     
  4. macrumors 68000

    Josh

    Joined:
    Mar 4, 2004
    Location:
    State College, PA
    #4
    One of your Tiger install CD's should have the developer tools package on them (not sure if the CD is specifically labled or not).

    Just install that package, and it will install GCC (Gnu C Compiler), XCode, Interface Builder, and some other things.

    If the CD is not labeled, I'm thining it might be CD #2 (not sure, because I'm not at home right now).
     
  5. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #5
    Just go to connect.apple.com, make a free account, login and download Xcode 2.4 which includes GCC 4 and GCC 3, which is all you need to get started :)
     
  6. macrumors regular

    Joined:
    Jun 4, 2006
    Location:
    B-Town, India
    #6
    When in doubt, gcc all your projects. It looks like XCode has it.
     
  7. macrumors 604

    GFLPraxis

    Joined:
    Mar 17, 2004
    #7
    Use XCode, or gcc via terminal.
     
  8. macrumors 68040

    plinden

    Joined:
    Apr 8, 2004
    #8
    gcc is an open source compiler, available for OS X, Linux and XP (via cygwin or MinGW) and other *nixes. It's pretty much standard for open source development.
     
  9. thread starter macrumors newbie

    Joined:
    Jun 7, 2006
    #9
    OK I am a total noob at this. I downloaded the file from apple's website. Installed XcodeTools.mpkg and the gcc 4 package. Now what do I do?
    I ran XCode and said new project which C do I use (Carbon C++ App, Carbon C++ Standard App, C++ Tool, C++ Dynamic Library, Standard Dynamic Library)

    Also, how do I open gcc? Thanks.

    Joe
     
  10. macrumors 68040

    plinden

    Joined:
    Apr 8, 2004
    #10
    If you're following your teacher using the command line, the best thing to do is just open Terminal. XCode is really for building GUIs and you won't learn a lot about the inner workings of C using it.

    Type "which gcc" and it will tell you whether it's installed correctly:
    Code:
    which gcc
    Create a subdirectory, e.g. projects and cd to it:
    Code:
    mkdir projects
    cd projects
    Look for examples of simple C programs (everyone does HelloWorld.c), and compile and run it (the following is the simplest way of compiling and writes the program executable to a.out):
    Code:
    gcc HelloWorld.c
    ./a.out
     
  11. thread starter macrumors newbie

    Joined:
    Jun 7, 2006
    #11
    Thanks a lot everyone (esp plinden) . I am going to have to play around with this. Although, I am still kind of dissapointed that I had to download this whole big Xcode developers suite if I just needed a C Compiler. I still really wanted one like DevC++ on XP. That is what my teacher is using, he is not using the command prompt and I dont want to use the terminal. Something basic but gets the job done. XCode has a lot of stuff I really don't need. If there is anymore input I would definately appreciate it. Thanks.
    Joe
     
  12. macrumors 6502a

    steelphantom

    Joined:
    Oct 15, 2005
    #12
    If all you're looking for is a simple C/C++ compiler, try CPP Edit. It's great for simple one-file programs, especially if you don't want to use the terminal.
     
  13. slb
    macrumors 6502

    Joined:
    Apr 15, 2005
    Location:
    New Mexico
    #13
    GCC is the same compiler used by Dev-C++. Dev-C++ uses MinGW, a Windows port of the GNU tools, which includes GCC.
     
  14. macrumors 6502

    Joined:
    Jul 25, 2006
    #14
    If you're just writing simple C++ apps, just create a "C++ tool" within Xcode. Unless there are some special libraries that come with that Dev-C++ thing you're talking about you shouldn't have any trouble following along with your teacher.

    You don't have to use the command line at all this way and you get nice things like auto-completion and project management. But if you don't want any of those features, you can just ignore them. You can just use the text editor and the "Build" button.

    And I disagree with the idea that Xcode is mainly for GUI development. I've done a fair amount of work in it that doesn't involve building GUI's at all.
     
  15. macrumors member

    Joined:
    Aug 14, 2006
    #15
    gcc is the compiler. There are any number of editors you can use, such as xcode, cpp edit, and many others. But don't confuse your terminology, gcc is a compiler, you now are looking for an editor :)

    Dev C++ is also an editor, it uses gcc as its compiler.
     
  16. thread starter macrumors newbie

    Joined:
    Jun 7, 2006
    #16
    Haha, oh dang. OK, I know I was missing something. I am looking for a editor than. I will try that cpp edit. Thanks again.

    So I guess the question is:

    What is the best C editor? Thanks.

    Joe
     
  17. macrumors 68000

    Soulstorm

    Joined:
    Feb 1, 2005
    #17
    Xcode! You're welcome :).
     
  18. macrumors 6502a

    Palad1

    Joined:
    Feb 24, 2004
    Location:
    London, UK
    #18
    let's just say it starts with V and ends with I

    :X!
     
  19. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #19
    Not realy the best choice for a beginner programmer ;)
     
  20. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #20
    TextWrangler is a pretty decent, flexible code editor, and it's free. There are lots of others available, but that's a good place to start (it's just a text editor so you'd still be using Terminal to compile and run your files). Xcode is good too, but there's a bunch of overhead involved in using that, as you've discovered already. If you're writing simple one-file text-based apps, Xcode is probably overkill.
     
  21. thread starter macrumors newbie

    Joined:
    Jun 7, 2006
    #21
    Exactly! Thank you very much, this is all I needed. Thanks again everyone.
    Joe
     
  22. Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #22
    You're evil. :D ed would be easier.
     
  23. macrumors 6502a

    elfin buddy

    Joined:
    Sep 16, 2001
    Location:
    Tuttlingen, Germany
    #23
    I usually prefer using the command line for working with C files. Xcode is fantastic for making GUI apps, but I just could never figure out a good way to make it compile straight-up C code with no bullsh*t. For the C course I took two years ago, I didn't want .h files or templates with #include <helloworld.h>. I just wanted a blank text file that would compile as C code and display results in another window, without having to create a whole project for it.

    I would love to use Xcode for compiling C, but it just seems like overkill. Can anyone suggest a way to make Xcode work that way, or should I stick with the terminal? (I have no beefs with the terminal at all...just looking for other options too)
     
  24. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #24
    File > New Project > C++ Tool.. then edit and build.
     
  25. macrumors 6502a

    elfin buddy

    Joined:
    Sep 16, 2001
    Location:
    Tuttlingen, Germany
    #25
    Nope, that ain't gonna do it. As I said above,

    It creates a project folder, a .xcodeproj file, and fills the .cpp file with this:

    Code:
    #include <iostream>
    
    int main (int argc, char * const argv[]) {
        // insert code here...
        std::cout << "Hello, World!\n";
        return 0;
    }
    Sorry, but not what I was looking for :eek:
     

Share This Page