starting C - command line


I am trying to learn C with OS X. I got a great book from O'Reilly (Practical C 3rd Edition) and the Cocoa book Apple put out through them as soon as it ships. But I can't get my helloworld.c to execute after compiling using %cc -g -ohello hello.c -- nor can I get any output out of the IDE that is installed with the developer tools.

Please tell me what I am doing wrong...


Not a Moderator
I just tried it and it seems to work. Try posting your source code and maybe we will catch the problem. Are there any error messages when you try to compile?

I would stay away from the IDE included with OSX until you are a little more familiar with C. Apple uses Objective C, which is explained inthe Cocoa book, but does require knowledge of plain C.

Good Luck


Dis Member
Are you telling it to execute? Is it giving a permissions error?

try ./hello



If you're using ProjectBuilder (Apple's IDE), you might want to try this: create a new project, and when it asks you what kind of project you want to create, scroll all the way down to the bottom of the list and choose "Standard Tool." When the ProjectBuilder window opens, you'll find a source called main.c. When you open main.c up in the ProjectBuilder window you'll discover that it has...guess what..."Hello World"! Already in there!

Saves typing, if nothing else. ProjectBuilder also has a syntax checker, which obviously vi and pico don't have, and building and running is an exercise in point-and-click. You can also compile and run C code from within ProjectBUilder, but I have found that interactive code works better if you execute the build from the command line.

There is something to be said for doing all your compiling and linking from the command line, at least so you know how to do it, but I find it quicker and more convenient to use ProjectBuilder. So long as you at least sort of know what ProjectBuilder is doing.

You can also create C++ code by creating a C++ tool, using the same method.