Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

103734

Guest
Original poster
Apr 10, 2007
723
0
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:
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
-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

Guest
Original poster
Apr 10, 2007
723
0
its times like this I wish there were a reputation system on this site.

Thanks alot!!:D
 

Sander

macrumors 6502a
Apr 24, 2008
521
67
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

Guest
Original poster
Apr 10, 2007
723
0
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.