Welcome to MacTalk Australia

the largest Australian community for Apple discussions and topics

Join the discussions, Register Now!
Results 1 to 15 of 15

Thread: C compiler

  1. #1

    Join Date
    Nov 2007
    Location
    Melbourne
    Posts
    588

    Default C compiler

    This may seem a silly question for some of you. Appologies

    Not having done any programming before I was looking at some of the c programing websites.
    The requirement is a compiler.
    In Leopard there is Terminal. Is that suitable, if not what is?

    If possible looking at something to start off at no cost.

    Just need a bit of guidance here as this is all new to me.
    Mac Pro 2.8GHz 8 core 10.8 64GB iPhone 5 iPad3 3G 16GB
    MacBook Pro 3.0 GHz 13" retina

  2. #2

    Default

    Xcode comes with OS X and is part of the developer tools. Just install it and you'll be ready to rock.

    Tools - Xcode

  3. #3

    Join Date
    Nov 2007
    Location
    Melbourne
    Posts
    588

    Default

    Quote Originally Posted by marc View Post
    Xcode comes with OS X and is part of the developer tools. Just install it and you'll be ready to rock.

    Tools - Xcode
    Great. Thanks marc for leading me in the right direction there.

    For anyone else that responds I won't ignore you. Going out for a while. I'll check in later.
    Mac Pro 2.8GHz 8 core 10.8 64GB iPhone 5 iPad3 3G 16GB
    MacBook Pro 3.0 GHz 13" retina

  4. #4

    Join Date
    Jul 2005
    Location
    Sydney
    Posts
    12,045

    Default

    Yep Xcode Tools will install what you need.

    And then from the command line (Terminal) you can gcc and away you go.

  5. #5

    Join Date
    Jan 2004
    Location
    Sydney
    Posts
    5,960

    Default

    As indicated, install Xcode. It contains the gcc compiler as used on Linux and various other unix platforms.

  6. #6

    Join Date
    Nov 2007
    Location
    Melbourne
    Posts
    588

    Default

    Quote Originally Posted by purana View Post
    As indicated, install Xcode. It contains the gcc compiler as used on Linux and various other unix platforms.
    Installed Xcode. Just don't understand the gcc bit and terminal.

    Opened terminal. Typed in gcc. and nothing. Is that what I'm meant to do?
    Mac Pro 2.8GHz 8 core 10.8 64GB iPhone 5 iPad3 3G 16GB
    MacBook Pro 3.0 GHz 13" retina

  7. #7

    Join Date
    Feb 2005
    Location
    Brunswick, Victoria
    Posts
    4,780

    Default

    gcc should come up with

    gcc: no input files

    There is an extras pack to install with the Xcode part if i remember correctly.

  8. #8

    Join Date
    Nov 2007
    Location
    Melbourne
    Posts
    588

    Default

    Nothing was the wrong terminology.

    Should have said "i686-apple-darwin9-gcc-4.0.1: no input files".
    Mac Pro 2.8GHz 8 core 10.8 64GB iPhone 5 iPad3 3G 16GB
    MacBook Pro 3.0 GHz 13" retina

  9. #9

    Join Date
    Jan 2004
    Location
    Sydney
    Posts
    5,960

    Default

    Quote Originally Posted by gtext View Post
    Nothing was the wrong terminology.

    Should have said "i686-apple-darwin9-gcc-4.0.1: no input files".

    gcc is a compiler, and it will compile blah.c source files. Your expected to code your program in c and then compile it. I wouldn't worry about gcc just yet, as you seriously need to code in c first.

    What are you hoping to do with a gcc compiler installed anyways? Learn to code??

  10. #10

    Join Date
    Jul 2005
    Location
    Sydney
    Posts
    12,045

    Default

    Well if you want to compile some C program, then you'd have to put in some flags and the source code gtext.

    e.g.
    gcc -Wall -W -ansi -pedantic -g myProgram.c

    Then to execute
    ./a.out

    Write your program. Save it as a .c file and then compile, run it. Debug if necessary. Rinse and repeat.

    Type man gcc in Terminal to find out more about gcc and what flags are available (parameters).

  11. #11

    Join Date
    Dec 2007
    Location
    Hobart, TAS
    Posts
    6,422

    Default

    To get you started:

    Long Pointers XCode 3.0 Tutorial

    Cocoa Dev Central: C Language Tutorial for Cocoa

    What exactly did you want to do anyway?! Learn to program Cocoa apps? Learn C? Learn Objective-C?!

  12. #12

    Join Date
    Jul 2005
    Location
    Sydney
    Posts
    12,045

    Default

    I think he just wants to test out some C programs and start coding simple stuff like getting Hello World to run (for a start).


  13. #13

    Join Date
    Nov 2007
    Location
    Melbourne
    Posts
    588

    Default

    Quote Originally Posted by Huy View Post
    I think he just wants to test out some C programs and start coding simple stuff like getting Hello World to run (for a start).

    Correct.

    Just trying to find out what program to start with. What to enter the code into.

    c programming that is.
    Mac Pro 2.8GHz 8 core 10.8 64GB iPhone 5 iPad3 3G 16GB
    MacBook Pro 3.0 GHz 13" retina

  14. #14

    Join Date
    Jul 2005
    Location
    Sydney
    Posts
    12,045

    Default

    At uni, they made us learn the 'hard' way.

    That is, regular old text editor in UNIX and doing everything via the command line (Terminal, xterm, shell, console, whatever you want to call it!).

    I suggest you use something like nano, pico to start off with (they are command line text editors). If you want to be 'hardcore' then you can start learning vi/vim.

    Then you can use the above gcc compiler to compile and run your programs. It is a good feeling when it compiles (free from error) and you have a little program that works.

    There are plenty of guides online, books, etc that you can use to start off on the path to programming. And there are people online who will help you out if you are having some trouble/don't understand something.

    So you can punch in something like this:
    #include<stdio.h>

    main()
    {
    printf("Hello World");
    }
    into your text editor and then compile it (save the file first ).

  15. #15

    Join Date
    Nov 2007
    Location
    Melbourne
    Posts
    588

    Default

    Quote Originally Posted by Huy View Post
    At uni, they made us learn the 'hard' way.

    That is, regular old text editor in UNIX and doing everything via the command line (Terminal, xterm, shell, console, whatever you want to call it!).

    I suggest you use something like nano, pico to start off with (they are command line text editors). If you want to be 'hardcore' then you can start learning vi/vim.

    Then you can use the above gcc compiler to compile and run your programs. It is a good feeling when it compiles (free from error) and you have a little program that works.

    There are plenty of guides online, books, etc that you can use to start off on the path to programming. And there are people online who will help you out if you are having some trouble/don't understand something.

    So you can punch in something like this:

    into your text editor and then compile it (save the file first ).
    Thanks Huy for that help. I've got something now to get me started.

    Now I understand the sequence - write then compile.

    I was thinking that the compiler was what I wrote the code into. Got it totally wrong there.

    Thank you everybody for your help.
    Mac Pro 2.8GHz 8 core 10.8 64GB iPhone 5 iPad3 3G 16GB
    MacBook Pro 3.0 GHz 13" retina

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •