Date: Sun, 01 Jun 1997 12:59:08 +0200 From: Gerhard Sittig <G.Sittig@abo.freiepresse.de> To: andrejs@crl.com Cc: FreeBSD-questions <FreeBSD-Questions@FreeBSD.ORG> Subject: Re: a.out programs are not executable! Makefiles Message-ID: <339155FC.6C81@abo.freiepresse.de> References: <3390380B.6A28@crl.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Andrejs Vanags wrote: > > However if I try to compile a simple hello.c program with gcc, the > result is a.out. If I type a.out it says command not found. > ... > HELP! how do I run a program after I do gcc and get a.out? typing a.out > does not work! > Once you read again the error message you will see the direction to go: "file not found" really means "don't know where a.out executable could be found" instead of "found it but didn't recognize the format". So all you have to do is to specify the program's location. Referring to `echo $PATH` you will find that the current directory isn't in it. That's the difference to the "usual" PC OSes. Commands are REALLY sought in the locations specified in $PATH ONLY and NOWHERE ELSE. You might a) specify the full path /home/user/project/a.out b) use a relative pathname ./a.out c) add the CWD to your PATH PATH=$PATH:.; export PATH I prefer methodes a) and b) and I really dislike methode c), since you might call the wrong version of 'test' or whatever just because there's one file called this name in the current directory ("by chance" :). Methods a) and b) make you much more aware of what you're doing. Regarding Makefiles: When using a somewhat intelligent version of make there is a reduced need for writing Makefiles on your own. 'gmake' for instance knows about a lot of dependencies and conventions and has a whole bunch of implicit rules to understand 'make hello' when there is a file named hello.c. You might want to use the -p (?) option to see the rule database (implicit and read from the Makefile - if any). You just have to write Makefiles once you want to add special options, use special libraries or your project has more than one source file. Once you get this far with experimenting there is a chance you can copy a Makefile from a different project. -- virtually yours -- G.Sittig@abo.FreiePresse.DE If you don't understand or are scared by any of the above ask your parents or an adult to help you.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?339155FC.6C81>