gcc questions

Matthew Miller mattdm at mattdm.org
Sun Nov 27 15:33:36 UTC 2005

On Sat, Nov 26, 2005 at 01:16:25PM +0200, Dotan Cohen wrote:
> Also, all files that gcc outputs are of the name a.out. I want it to
> give the .out file the original name of the file, with a .out. I have
> manned and discovered the -o option, whereby I can specify a filename,
> but I would prefer that it would read the original filename and use
> that. For instance:
> $gcc mycode.c
> $ls
> mycode.c    mycode.out
> How can I encourage this behaviour? Thank you.

Oh, hey, I missed this part of the question. There's a neat trick if you
have GNU Make, which you do on Fedora (and just about any Linux distro).
If you have a simple C program with just one source file and no special
linking needs, you can do this:

   make mycode

Note not mycode.c -- it'll automatically figure out that it can make the
executable mycode from mycode.c. And you don't even have to have a Makefile!

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

More information about the users mailing list