gcc questions

Matthew Miller mattdm at mattdm.org
Sun Nov 27 19:47:39 UTC 2005


On Sun, Nov 27, 2005 at 09:08:26PM +0200, Dotan Cohen wrote:
> As for the -o option, I would like to have the compiler output
> filename.out for filename.c without me having to write it out every
> time. Is this possible? If the answer to that question lies in the man
> page, then it is in the second half!


The real answer to this is: learn how to write a simple makefile. You can
find some quick tutorials on the web. It seems intimidating, but although
makefiles *can* get really complicated, a basic one is very simple. You have
a list of things you want to make, and for each thing, a list of the steps
to make it. (Really, the biggest gotcha is the strange syntax, where
indentation *must* be done with tabs.)

Or, since you're staring from scratch, you could use scons, which is
designed as a more modern replacement for make. It's included in Fedora
Extras.

A simple SContruct file for your "filename.c" would look like this:

  Program('filename.c')

and that's it (no indentation, though). You'd then type "scons" to build it.

Hmmm -- on my system, I don't need to link in libm explicitly to get sqrt()
-- it just works. But if you *do* need a library, do this:

  Program('filename.c',LIBS='m')




-- 
Matthew Miller           mattdm at mattdm.org          <http://mattdm.org/>
Boston University Linux      ------>              <http://linux.bu.edu/>




More information about the users mailing list