Development tools and cc

ieldib

Registered
i wrote a simple c++ terminal program that i would like to compile and run how would i go about doing this using cc , and how can i create CLI terminal programs using the Developers Tools ?
 
I don't actually know how to do it with the Developers tools, just with the plain old command-line. Actually, I use makefiles, which are wonderful timesavers once you spend the (short) time it takes to learn them. Anyway.

for each source file, make an object file:
cc -c sourcefile1.c (or .cpp, whatever)
...
then, make an executable from the objects:
cc -o executablefile objectfile1.o objectfile2.o ...

You can actually go straight from the source to executable, but then it just throws away intermediate object files, so if you changed one source file, you would have to recompile the whole shebang. (This is where make comes in handy)

edit - stupid BBcode ate my formatting!
 
Well, try man make for details, obviously; not really the most insightful thing for the big picture though.

Here, I'll post a couple of simple makefiles from some assignments for examples.

Um, off the top of my head, the basics go like this:

The makefile should just be called "makefile" (any capitalization is OK)

If you just type "make" the default target is "all", otherwise you can type "make sometarget" to be more specific.

Each entry is of the form
<target>:<tab><required files>
<tab><command>
<tab><command>
...

The way make saves you time is by tracking modification dates on files - if a file is older than some target it is required for, then that target needs to be remade, otherwise that target is already done. It basically automatically figures out the minimum amount of recompiling you can get away with (as long as you correctly tell it what files are involved in any compiling you do).

These examples use C source and gcc for the compiler, but you can use make for anything - java code, gnuplot rendering, recipe collections - you get the idea.
 
im sorry to bother ya again but i cant download that file , it says that IE doesnt have the mime or plugin to handle that type of file or something like that :(
 
Funny, iCab does OK. Maybe if you specify downloading, rather than just clicking the link?
 
Originally posted by ieldib
im sorry to bother ya again but i cant download that file , it says that IE doesnt have the mime or plugin to handle that type of file or something like that :(

Option-click the link.
 
Back
Top