PDA

View Full Version : Help Understanding Something From "Programing In Objective-C"




103734
Sep 1, 2008, 05:38 PM
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
// 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
[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:



lee1210
Sep 1, 2008, 07:16 PM
-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

103734
Sep 1, 2008, 07:22 PM
its times like this I wish there were a reputation system on this site.

Thanks alot!!:D

Sander
Sep 2, 2008, 08:41 AM
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".

103734
Sep 2, 2008, 04:53 PM
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".

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.