Help Understanding Something From "Programing In Objective-C"

Discussion in 'Mac Programming' started by 103734, Sep 1, 2008.

  1. Guest

    Joined:
    Apr 10, 2007
    #1
    Well I got the book, Programing in Objective-C by Stephen G. Kochan, and im having a problem with the part of the book that deals with compiling your first program in terminal.

    I have a file named main.m with a sample code shown bellow
    Code:
    // first program example
    #import <stdio.h>
    
    int main (int argc, const char *argv[])
    {
    
    printf ("Programing is ****ing funerific. \n");
    
    return 0;
    }
    then I try to compile it using the command shown in the book (command from book bellow this)

    gcc main.m -o myprogram -1 objc Compile main.m & call it myprogram

    and I get this error
    Code:
    [1] 1351
    -bash: call: command not found
    myname-myname-laptopname-2:MySrc supersteve9219$ i686-apple-darwin9-gcc-4.0.1: main.m: No such file or directory
    i686-apple-darwin9-gcc-4.0.1: objc: No such file or directory
    i686-apple-darwin9-gcc-4.0.1: Compile: No such file or directory
    i686-apple-darwin9-gcc-4.0.1: main.m: No such file or directory
    i686-apple-darwin9-gcc-4.0.1: no input files
    
    But when I use just

    gcc main.m -o myprogram

    it compiles without errors and I get the executable file in the MySrc directory, Why does the command from the book give me erros but when I remove "-1 objc Compile main.m & call it myprogram" it works :confused:
     
  2. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    -l not -1 (that's a lowercase 'L')

    This says "use the library...". There is absolutely nothing in this program that uses objective-C libraries, so it's not necessary here, but it will be later. This program is pure C, so the "regular" C compilation program and flags work fine.

    -Lee
     
  3. thread starter Guest

    Joined:
    Apr 10, 2007
    #3
    its times like this I wish there were a reputation system on this site.

    Thanks alot!!:D
     
  4. macrumors 6502

    Joined:
    Apr 24, 2008
    #4
    Also, the "& call it myprogram" part is not to be typed. I think I remember from the book that this particular part had confusing typography, as if you had to enter it as well. But it is addressed at you, the reader.

    Since you did type it, the shell was looking for a program called "call", to pass it the two arguments "it" and "myprogram". This is why you had an error saying "-bash: call: command not found".
     
  5. thread starter Guest

    Joined:
    Apr 10, 2007
    #5
    Yea I was thinking "Compile main.m & call it myprogram" was a typo, I think he meant to put it in Italic and not bold.
     

Share This Page